diff options
| author | Laurent Smet <las@odoo.com> | 2020-07-29 06:57:45 +0000 |
|---|---|---|
| committer | Laurent Smet <las@odoo.com> | 2020-08-06 11:20:27 +0000 |
| commit | 34d53ebc87187aa3609db5f1ca515e9f12e47928 (patch) | |
| tree | 43c08cb7f3973f65c7419caf96064adfeb28685d /odoo/tests | |
| parent | 9dc3057e8eb82d9237457167641585655f249c3e (diff) | |
[REF] account: Add generic 'AccountTestInvoicingHttpCommon' class
Thanks to this setup, we will be able to run the tours independently to any demo data.
To do so, the HttpSavepointCase is born to do the same as HttpCase but with a setUpClass.
--task: 2290120
Diffstat (limited to 'odoo/tests')
| -rw-r--r-- | odoo/tests/common.py | 45 |
1 files changed, 27 insertions, 18 deletions
diff --git a/odoo/tests/common.py b/odoo/tests/common.py index f5a83487cf1..191f25003a3 100644 --- a/odoo/tests/common.py +++ b/odoo/tests/common.py @@ -1234,15 +1234,14 @@ class ChromeBrowser(): return m[0] return replacer -class HttpCase(TransactionCase): - """ Transactional HTTP TestCase with url_open and Chrome headless helpers. - """ + +class HttpCaseCommon(BaseCase): registry_test_mode = True browser = None browser_size = '1366x768' def __init__(self, methodName='runTest'): - super(HttpCase, self).__init__(methodName) + super().__init__(methodName) # v8 api with correct xmlrpc exception handling. self.xmlrpc_url = url_8 = 'http://%s:%d/xmlrpc/2/' % (HOST, odoo.tools.config['http_port']) self.xmlrpc_common = xmlrpclib.ServerProxy(url_8 + 'common') @@ -1251,21 +1250,8 @@ class HttpCase(TransactionCase): cls = type(self) cls._logger = logging.getLogger('%s.%s' % (cls.__module__, cls.__name__)) - @classmethod - def start_browser(cls): - # start browser on demand - if cls.browser is None: - cls.browser = ChromeBrowser(cls._logger, cls.browser_size, cls.__name__) - cls.addClassCleanup(cls.terminate_browser) - - @classmethod - def terminate_browser(cls): - if cls.browser: - cls.browser.stop() - cls.browser = None - def setUp(self): - super(HttpCase, self).setUp() + super().setUp() if self.registry_test_mode: self.registry.enter_test_mode(self.cr) self.addCleanup(self.registry.leave_test_mode) @@ -1278,6 +1264,19 @@ class HttpCase(TransactionCase): self.opener = requests.Session() self.opener.cookies['session_id'] = self.session_id + @classmethod + def start_browser(cls): + # start browser on demand + if cls.browser is None: + cls.browser = ChromeBrowser(cls._logger, cls.browser_size, cls.__name__) + cls.addClassCleanup(cls.terminate_browser) + + @classmethod + def terminate_browser(cls): + if cls.browser: + cls.browser.stop() + cls.browser = None + def url_open(self, url, data=None, files=None, timeout=10, headers=None, allow_redirects=True): self.env['base'].flush() if url.startswith('/'): @@ -1418,6 +1417,16 @@ class HttpCase(TransactionCase): return res +class HttpCase(HttpCaseCommon, TransactionCase): + """ Transactional HTTP TestCase with url_open and Chrome headless helpers. + """ + pass + + +class HttpSavepointCase(HttpCaseCommon, SavepointCase): + pass + + def users(*logins): """ Decorate a method to execute it once for each given user. """ @decorator |
