Populating random data for testing
So far, we have seen test cases that have been used to detect errors or bugs in business logic. However, at times we need to test our development with large amounts of data. Generating large amounts of data can be a tedious job. Odoo provides a set of tools that helps you to generate a lot of random data for your model. In this recipe, we will use the populate command to generate test data for the library.book model.
Getting ready
For this recipe, we will continue using the my_library module from the previous recipe. We will add the _populate_factories method, which will be used to generate test data.
How to do it...
Follow these steps to generate data for the library.book model:
- Add a
populatefolder in themy_librarymodule. Also, add an__init__.pyfile with this content:from . import library_data
- Add a
my_library/populate/library_data.pyfile and add this code to generate the book's data:from odoo import models from...