[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.
This commit is contained in:
Xavier Morel 2024-07-17 15:04:56 +02:00
parent a5c514ad6e
commit 5126fd8053

View File

@ -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':