From 5126fd8053682b8d7ffcbb13e3177433e49a6aa5 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Wed, 17 Jul 2024 15:04:56 +0200 Subject: [PATCH] [IMP] core: ensure web.base.url is correctly set up Finally went to fix the issue that web.base.url is not correctly set up by the test suite and thus things like `PullRequest.url` don't return the right URL when running tests. The answer I re-discovered yet again is that one only has to log in as an admin (`base.group_system`) while providing a `base_location` env key. This is done automatically when logging via the frontend, under the assumption that this is the "correct" url, but when logging in via RPC it has to be done manually as that's more internal and we might use e.g. scripts on the same server to manipulate the instance. --- conftest.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/conftest.py b/conftest.py index 8e9d54ef..66afa127 100644 --- a/conftest.py +++ b/conftest.py @@ -375,12 +375,14 @@ def wait_for_server(db, port, proc, mod, timeout=120): try: uid = xmlrpc.client.ServerProxy( - 'http://localhost:{}/xmlrpc/2/common'.format(port))\ - .authenticate(db, 'admin', 'admin', {}) + f'http://localhost:{port}/xmlrpc/2/common' + ).authenticate(db, 'admin', 'admin', { + 'base_location': f"http://localhost:{port}", + }) mods = xmlrpc.client.ServerProxy( - 'http://localhost:{}/xmlrpc/2/object'.format(port))\ - .execute_kw( - db, uid, 'admin', 'ir.module.module', 'search_read', [ + f'http://localhost:{port}/xmlrpc/2/object' + ).execute_kw( + db, uid, 'admin', 'ir.module.module', 'search_read', [ [('name', '=', mod)], ['state'] ]) if mods and mods[0].get('state') == 'installed':