Adding Python test cases
Python test cases are used to check the correctness of business logic. In Chapter 5, Basic Server-Side Development, you saw how you can modify the business logic of our existing app. This makes it even more important, as customization might break the app's functionality. In this chapter, we will write a test case to validate the business logic to change a book's state.
Getting ready
We will be using the my_library
module from the Chapter17/r0_initial_module
directory of the GitHub repository.
How to do it...
Follow these steps to add Python test cases to the my_library
module:
- Add a new file,
tests/__init__.py
, as follows:from . import test_book_state
- Add a
tests/test_book_state.py
file, and add the test case, as follows:from odoo.tests.common import TransactionCase class TestBookState(TransactionCase): def setUp(self, *args, **kwargs): ...