Welcome to Destral documentation!¶
Release v0.20.1
Contents:
Destral testing library¶
A library to do tests with our OpenERP Server (v5)
Note
The API is not stable, and can be changed.
Code as if the next guy to maintain your code is a homicidal maniac who knows where you live.
—Kathy Sierra and Bert Bates
Running tests¶
To run your tests call destral from the command line. Options to the destral command are:
Usage: destral [OPTIONS]
Options:
--enable-coverage
--report-coverage
--dropdb/no-dropdb
--requirements/no-requirements
-m, --modules TEXT
-t, --tests TEXT
--help Show this message and exit.
where -m are the modules to be tested and -t the tests to run. For the -t parameter is needed to pass full test class and method. Eg: SomeTestClass.test_method
If no specific tests are defined into the module, destral will test:
- Correct installation of the module.
- All the views defined in the module are ok.
- Definition of access rules for all the models of the module
If you have run with the –enable-coverage option a .coverage file will be generated with the results and you can see the report executing:
$ coverage report
If your want to reuse the database you can use –no-dropdb and this will keep the database after running all the tests. Then you can make destral use this database exporting the environment variable OPENERP_DB_NAME=database_name
If you are running the destral in local environment with all the requirements installed and you want to speed up the tests you can use the option –no-requirements to skip the requirements installation.
Configuring destral¶
All the configuration can be made with environment variables with prefix DESTRAL_
Variables definition¶
- DESTRAL_MODULE:
- Module to test
- DESTRAL_USE_TEMPLATE:
- If we want to use a template when creating a database for test, if this variable is set to True a database with name base must exists and will be used to create a temporally database for this test.
Configuring OpenERP¶
All configuration for OpenERP server can be made with environment variables with prefix OPENERP_ and will overwrite the defaults in tools.config.
Useful variables¶
- OPENERP_DB_NAME:
- A database to use, if this is set then the test framework assumes that the module is already installed and this database will not be deleted after the tests.
- OPENERP_UPDATE:
- If you want to update some modules during the initialization of OpenERP service Eg value: OPENERP_UPDATE={‘base’: 1, ‘crm’: 1}
Note
When developing is useful to have a database initialized and use OPENERP_DB_NAME variable to speed up the test.
API¶
destral.openerp¶
-
destral.openerp.
DEFAULT_USER
= 1¶ Default user id
destral.patch¶
-
class
destral.patch.
PatchNewCursors
[source]¶ Util to patch creation of new cursor.
This will always return the cursor created by Transaction
destral.testing¶
-
class
destral.testing.
OOTestCase
(methodName='runTest')[source]¶ Base class to inherit test cases from for OpenERP Testing Framework.
-
database
¶ Database used in the test.
-
require_demo_data
= False¶ Require demo data to run the tests.
-
destral.transaction¶
-
class
destral.transaction.
Singleton
(mcs, name, bases, dict_)[source]¶ Metaclass for singleton pattern.
Copyright: Tryton Project
destral.utils¶
-
destral.utils.
update_config
(config, **kwargs)[source]¶ Updates config dictionary from keyword arguments.
-
destral.utils.
detect_module
(path)[source]¶ Detect if a path is part of a openerp module or not
Parameters: path – to examine Returns: None if is not a module or the module name
-
destral.utils.
module_exists
(module)[source]¶ Check if a python module exists.
This is used to check if a module have its own tests defined, Eg: addons.module_name.tests
Parameters: module – Module name to check Returns: True if exists or False if not
-
destral.utils.
get_dependencies
(module, addons_path=None, deps=None)[source]¶ Get all the dependencies of a module without database
Using __terp__.py files and is used to check requirements.txt in the dependencies.
Parameters: - module – Module to find the dependencies
- addons_path – Path to find the modules
Returns: a listt of dependencies.