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 hostel room’s state.
Getting ready
We will use the my_hostel
module from the Chapter18/00_initial_module
directory of the GitHub repository.
How to do it...
Follow these steps to add Python test cases to the my_hostel
module:
- Add a new file,
tests/__init__.py
, as follows:from . import test_hostel_room_state
- Add a
tests/test_hostel_room_state.py
file, and then add the test case, as follows:from odoo.tests.common import TransactionCase class TestHostelRoomState(TransactionCase): def setUp(self, *args, **kwargs): ...