Writing tests for your module using Python unit tests
Odoo supports different ways of writing addon module tests, YAML tests, and Python tests. Writing YAML tests for new modules is not encouraged by the editors, and it is quite possible that the support will be dropped altogether in a future version. Therefore, we will not cover these in this book, and we will instead focus on Python unit tests.
If you are familiar with the Python unit testing tools, you will be pleased to know that these are also available within the Odoo framework.
In this recipe, we will see how to write Python unit tests for the my_module
methods we wrote in the Define Model methods and use the API decorators recipe in Chapter 6, Basic Server-Side Development.
Getting ready
This recipe assumes that you have an instance ready with the code for the my_module
module defined in Chapter 4, Creating Odoo Modules, and the code in the Define Model methods and use the API decorators recipe from Chapter 6, Basic Server-Side Development...