Skip to main content

pytest plugin to test OpenERP modules

Project description

py.test plugin for testing OpenERP modules

Usage

install/update via:

pip install -U pytest-oerp

and to run tests type:

py.test --oerp-server-path=<path to openerp server/bin directory> \
        --oerp-db=<db name, default is test>

this will load OpenERP using the config on ~/.openerp_serverrc and create a pool and transaction for the choosen database for the testcases where you receive an oerp attribute.

Writting tests

Testcases only need to receive oerp to create a transaction on oerp an example follows:

def test_simple(oerp):
    product_obj = oerp.pool.get('product.product')
    product_ids = product_obj.search(oerp.cr, 1, [])

this will be run inside OpenERP like code in modules and you can use the full openerp api. You can only load stuff from OpenERP library inside functions, because the library is added to sys.path dynamically.

OpenERP API

As pytest-oerp is running inside OpenERP everything you need to do that can be done inside a module can be done in a pytest-oerp test. The usual cr, uid attributes are oerp.cr and 1 (that means the first user, usually admin). oerp also has a pool attribute that is useful.

Todo

There are a lot of polish and features that should be done but a tentative list would be:

  • support passing a configuration to OpenERP

  • more tests (always a good thing)

  • don’t depend on mock (great lib but probably unnecessary for this)

  • redirect print log

  • addini in pytest so you can configure with pytest.ini

  • lettuce support, but this will probably go in another package

Notes

The official repository of this plugin is at http://github.com/santagada/pytest-oerp

For more info on py.test see http://pytest.org

All work on the plugin has been sponsored by PROGE (http://www.proge.com.br)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pytest-oerp-0.1.2.tar.gz (2.7 kB view details)

Uploaded Source

File details

Details for the file pytest-oerp-0.1.2.tar.gz.

File metadata

  • Download URL: pytest-oerp-0.1.2.tar.gz
  • Upload date:
  • Size: 2.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for pytest-oerp-0.1.2.tar.gz
Algorithm Hash digest
SHA256 50c1cdd1487c62e9ba98c5b33b4a6251043e1123f732c3ef7a6aefa82160f1a4
MD5 9d00b97615e613f12c57ae143b974868
BLAKE2b-256 1e5bf115fc47849ffe384b41643aa8b347e9ed4a65649e7f419e0e67377173ef

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page