|
@ -3,7 +3,7 @@ |
|
|
# 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 odoo.modules.registry import Registry |
|
|
from odoo.modules.registry import Registry |
|
|
from odoo.tools import config |
|
|
|
|
|
|
|
|
from odoo.tools import config, mute_logger |
|
|
from odoo.tests.common import TransactionCase, at_install, post_install |
|
|
from odoo.tests.common import TransactionCase, at_install, post_install |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -52,6 +52,7 @@ class TestDatabaseCleanup(TransactionCase): |
|
|
# must be removed by the wizard |
|
|
# must be removed by the wizard |
|
|
with self.assertRaises(ProgrammingError): |
|
|
with self.assertRaises(ProgrammingError): |
|
|
with self.env.registry.cursor() as cr: |
|
|
with self.env.registry.cursor() as cr: |
|
|
|
|
|
with mute_logger('odoo.sql_db'): |
|
|
cr.execute('select database_cleanup_test from res_partner') |
|
|
cr.execute('select database_cleanup_test from res_partner') |
|
|
|
|
|
|
|
|
# create a data entry pointing nowhere |
|
|
# create a data entry pointing nowhere |
|
@ -77,8 +78,6 @@ class TestDatabaseCleanup(TransactionCase): |
|
|
'insert into ir_attachment (name, res_model, res_id, type) values ' |
|
|
'insert into ir_attachment (name, res_model, res_id, type) values ' |
|
|
"('test attachment', 'database.cleanup.test.model', 42, 'binary')") |
|
|
"('test attachment', 'database.cleanup.test.model', 42, 'binary')") |
|
|
self.env.registry.models.pop('x_database.cleanup.test.model') |
|
|
self.env.registry.models.pop('x_database.cleanup.test.model') |
|
|
self.env.registry._fields_by_model.pop( |
|
|
|
|
|
'x_database.cleanup.test.model') |
|
|
|
|
|
purge_models = self.env['cleanup.purge.wizard.model'].create({}) |
|
|
purge_models = self.env['cleanup.purge.wizard.model'].create({}) |
|
|
purge_models.purge_all() |
|
|
purge_models.purge_all() |
|
|
# must be removed by the wizard |
|
|
# must be removed by the wizard |
|
@ -112,6 +111,7 @@ class TestDatabaseCleanup(TransactionCase): |
|
|
purge_tables.purge_all() |
|
|
purge_tables.purge_all() |
|
|
with self.assertRaises(ProgrammingError): |
|
|
with self.assertRaises(ProgrammingError): |
|
|
with self.env.registry.cursor() as cr: |
|
|
with self.env.registry.cursor() as cr: |
|
|
|
|
|
with mute_logger('odoo.sql_db'): |
|
|
cr.execute('select * from database_cleanup_test') |
|
|
cr.execute('select * from database_cleanup_test') |
|
|
|
|
|
|
|
|
def tearDown(self): |
|
|
def tearDown(self): |
|
|