From 841a5e7c2d8ebbf09d88fe3904fbf914e6b99b56 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Wed, 6 Nov 2013 12:55:47 +0100 Subject: [PATCH] [FIX] db handling being a pain in the ass On runbot the base url dispatches into a unknown void of no db being selected and the CMS thus 404s. For human beings there are additional links to special subdomains setting the right db in the right place (or maybe the right dbfilter, whatever) but that doesn't work right for the crawler test suite. Instead go through /web/ with a forced db selection, this *should* set the db correctly in the user's session even if he's anonymous and thus allows us to browse said db. No idea if this fevered idea is actually going to work. bzr revid: xmo@openerp.com-20131106115547-0ozlex09svkecrhb --- addons/website/tests/test_requests.py | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/addons/website/tests/test_requests.py b/addons/website/tests/test_requests.py index 97de424262b..8af4bb7de60 100644 --- a/addons/website/tests/test_requests.py +++ b/addons/website/tests/test_requests.py @@ -61,18 +61,23 @@ class CrawlSuite(unittest2.TestSuite): ])) def _authenticate(self, user, password): - if user is None: return - - url = 'http://localhost:{port}/login?{query}'.format( + # force tools.config['db_name'] in user session so opening `/` doesn't + # blow up in multidb situations + self.opener.open('http://localhost:{port}/web/?db={db}'.format( port=tools.config['xmlrpc_port'], - query=urllib.urlencode({ - 'db': tools.config['db_name'], - 'login': user, - 'key': password, - }) - ) - auth = self.opener.open(url) - assert auth.getcode() < 400, "Auth failure %d" % auth.getcode() + db=urllib.quote_plus(tools.config['db_name']), + )) + if user is not None: + url = 'http://localhost:{port}/login?{query}'.format( + port=tools.config['xmlrpc_port'], + query=urllib.urlencode({ + 'db': tools.config['db_name'], + 'login': user, + 'key': password, + }) + ) + auth = self.opener.open(url) + assert auth.getcode() < 400, "Auth failure %d" % auth.getcode() def _wrapped_run(self, result, debug=False): paths = collections.deque(['/'])