Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Medium Constribution] Add unittests for functions in openupgradelib/openupgrade.py #9

Open
bwrsandman opened this issue Aug 13, 2015 · 3 comments

Comments

@bwrsandman
Copy link
Contributor

There are the beginnings of a unittest structure in tests/test_openupgradelib.py

The goal is to increase coverage and guarantee code stability of functions in openupgradelib by:

  1. running each function
  2. mocking a openerp installation, database, modules
  3. checking the calls run on the mocks
  4. having a mock database built in travis or in setup
  5. checking that openupgradelib correctly manipulates the data

Things to avoid:

  1. Implementation tests. This means testing a whole migration at once. A unittest is supposed to test by units. Implementation testing for whole migrations should be done in https://github.com/OCA/openupgrade
  2. Using mock to give out the expected answer. Mock should take care of the background details. We don't want to be testing the mock object, we want to test the calls.
  3. Testing the best cases. Test edge cases. Example: single id, duplicate ids, no ids, unicode instead of str, None as a parameter.
  4. Testing version specific migrations. As said in 1. these scripts should be seen as version agnostic and must be usable for all migrations including non-major migrations.
@bwrsandman bwrsandman changed the title Add unittests for functions in openupgradelib/openupgrade.py [Medium Constribution] Add unittests for functions in openupgradelib/openupgrade.py Aug 13, 2015
@pedrobaeza
Copy link
Member

I can do it, but I need a first example in which basing my code, because I have never worked with mocks.

@bwrsandman
Copy link
Contributor Author

Take a look at tests/test_openupgradelib.py It uses Mocks to be able to import openupgrade from openupgradelib.

@bwrsandman
Copy link
Contributor Author

Done in pedrobaeza#1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants