diff options
| author | Raphael Collet <rco@odoo.com> | 2020-07-02 08:56:08 +0000 |
|---|---|---|
| committer | Raphael Collet <rco@odoo.com> | 2020-07-08 11:58:33 +0000 |
| commit | dd8a6b8a8299afaac699d04f2ed886ff85c685fe (patch) | |
| tree | 6352a86a099bdcf8e0252364c0f0a670018feb9f /odoo/tests | |
| parent | 04250d80163bb785b674b85fe24354c9d999efea (diff) | |
[ADD] test_new_api: tests on queries made by create with computed fields
closes odoo/odoo#54209
Related: odoo/upgrade#1464
Signed-off-by: Raphael Collet (rco) <rco@openerp.com>
Diffstat (limited to 'odoo/tests')
| -rw-r--r-- | odoo/tests/common.py | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/odoo/tests/common.py b/odoo/tests/common.py index 84ab36e5008..dc557682709 100644 --- a/odoo/tests/common.py +++ b/odoo/tests/common.py @@ -381,7 +381,7 @@ class BaseCase(TreeCase, MetaCase('DummyCase', (object,), {})): return self._assertRaises(exception, **kwargs) @contextmanager - def assertQueries(self, expected): + def assertQueries(self, expected, flush=True): """ Check the queries made by the current cursor. ``expected`` is a list of strings representing the expected queries being made. Query strings are matched against each other, ignoring case and whitespaces. @@ -396,9 +396,16 @@ class BaseCase(TreeCase, MetaCase('DummyCase', (object,), {})): def get_unaccent_wrapper(cr): return lambda x: x + if flush: + self.env.user.flush() + self.env.cr.precommit() + with patch('odoo.sql_db.Cursor.execute', execute): with patch('odoo.osv.expression.get_unaccent_wrapper', get_unaccent_wrapper): yield actual_queries + if flush: + self.env.user.flush() + self.env.cr.precommit() self.assertEqual( len(actual_queries), len(expected), |
