Browse Source

Merge pull request #511 from hbrunn/9.0-database_cleanup_fix_tests

[9.0] database_cleanup fix tests
pull/499/head
Pedro M. Baeza 8 years ago
committed by GitHub
parent
commit
b83123a936
  1. 6
      .travis.yml
  2. 6
      database_cleanup/tests/test_database_cleanup.py

6
.travis.yml

@ -21,10 +21,8 @@ env:
matrix: matrix:
- LINT_CHECK="1" - LINT_CHECK="1"
- TRANSIFEX="1" - TRANSIFEX="1"
- TESTS="1" ODOO_REPO="odoo/odoo" EXCLUDE=database_cleanup
- TESTS="1" ODOO_REPO="OCA/OCB" EXCLUDE=database_cleanup
- TESTS="1" ODOO_REPO="odoo/odoo" INCLUDE=database_cleanup
- TESTS="1" ODOO_REPO="OCA/OCB" INCLUDE=database_cleanup
- TESTS="1" ODOO_REPO="odoo/odoo"
- TESTS="1" ODOO_REPO="OCA/OCB"
virtualenv: virtualenv:
system_site_packages: true system_site_packages: true

6
database_cleanup/tests/test_database_cleanup.py

@ -2,6 +2,7 @@
# © 2016 Therp BV <http://therp.nl> # © 2016 Therp BV <http://therp.nl>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from psycopg2 import ProgrammingError from psycopg2 import ProgrammingError
from openerp.modules.registry import RegistryManager
from openerp.tools import config from openerp.tools import config
from openerp.tests.common import TransactionCase from openerp.tests.common import TransactionCase
@ -57,6 +58,9 @@ class TestDatabaseCleanup(TransactionCase):
}) })
purge_modules = self.env['cleanup.purge.wizard.module'].create({}) purge_modules = self.env['cleanup.purge.wizard.module'].create({})
# this reloads our registry, and we don't want to run tests twice # this reloads our registry, and we don't want to run tests twice
# we also need the original registry for further tests, so save a
# reference to it
original_registry = RegistryManager.registries[self.env.cr.dbname]
config.options['test_enable'] = False config.options['test_enable'] = False
purge_modules.purge_all() purge_modules.purge_all()
config.options['test_enable'] = True config.options['test_enable'] = True
@ -64,6 +68,8 @@ class TestDatabaseCleanup(TransactionCase):
self.assertFalse(self.env['ir.module.module'].search([ self.assertFalse(self.env['ir.module.module'].search([
('name', '=', 'database_cleanup_test'), ('name', '=', 'database_cleanup_test'),
])) ]))
# reset afterwards
RegistryManager.registries[self.env.cr.dbname] = original_registry
# create an orphaned table # create an orphaned table
self.env.cr.execute('create table database_cleanup_test (test int)') self.env.cr.execute('create table database_cleanup_test (test int)')

Loading…
Cancel
Save