Book Image

Odoo Development Cookbook

By : Holger Brunn, Alexandre Fayolle, Daniel Reis
Book Image

Odoo Development Cookbook

By: Holger Brunn, Alexandre Fayolle, Daniel Reis

Overview of this book

Odoo is a full-featured open source ERP with a focus on extensibility. The flexibility and sustainability of open source is also a key selling point of Odoo. It is built on a powerful framework for rapid application development, both for back-end applications and front-end websites. The book starts by covering Odoo installation and administration, and provides a gentle introduction to application development. It then dives deep into several of the areas that an experienced developer will need to use. You’ll learn implement business logic, adapt the UI, and extend existing features.
Table of Contents (23 chapters)
Odoo Development Cookbook
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Writing tests for your module using Python unit tests


YAML is not the only way of writing tests with Odoo. 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 Chapter 5, Basic Server Side Development, in the recipe Define Model methods and use the API decorators.

Getting ready

This recipe assumes you have a instance ready with the code for the my_module module defined in Chapter 3, Creating Odoo Modules, and the code from Chapter 5, Basic Server Side Development, in the recipe Define Model methods and use the API decorators.

How to do it…

In order to write unit tests for the module, perform the following steps:

  1. Create a subdirectory called tests inside the addon module directory:

    $mkdir my_module/tests
    
  2. Create an __init__.py file in that directory with the following contents:

    from . import test_library
  3. Create a test_library...