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 generate a lot of random data for your model. In this recipe, we will use the populate command to generate test data for the hostel.room and hostel.room.member models.
Getting ready
For this recipe, we will continue using the my_hostel 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 hostel.room model:
- Add a
populatefolder to themy_hostelmodule. Also, add an__init__.pyfile with this content:from . import hostel_data
- Add a
my_hostel/populate/hostel_data.pyfile, and then add this code to generate the hostel room’s data...