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 YAML


Odoo supports different ways of writing addon module tests, YAML tests, and Python tests. In this recipe, we will see how to write YAML 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 an instance ready with the code for the my_module module defined in Chapter 3, Creating Odoo Modules, and the code from the Define Model methods and use the API decorators recipe in Chapter 5, Basic Server Side Development.

How to do it…

In order to write YAML unit tests for my_module, you need to follow these steps:

  1. Edit the __openerp__.py file of the module, and add the test's entry:

    {  # …
        'test': ['test/test_books.yml']
    }
    
  2. Create a test directory in my_module:

    $ mkdir test
    
  3. Create a file called test_books.yml in the directory. Add a test description at the top:

    -
      Test LibraryBook.change_state
    
  4. Add a step changing the current...