Commit 8b9964a6 authored by Laurent Bachelier's avatar Laurent Bachelier

Add test for config initialization at the first request

And use a simpler method to find out the absolute root URL, which also
avoids storing :80 or :443 when the default HTTP or HTTPS port is used.
parent 8354d217
......@@ -108,8 +108,7 @@ class Context(object):
config.save()
# store the absolute root url (useful when in CLI)
if not config.data["web"].get("root_url"):
config.data["web"]["root_url"] = urlparse.urlunsplit(
(self.req.scheme, self.req.host, self.root_url.href, '', ''))
config.data["web"]["root_url"] = self.req.host_url+self.root_url.href
config.save()
def _init_templates(self):
......
......@@ -138,3 +138,11 @@ class BaseWebTest(TestCase):
self.app.post('/?_method=GET', status=405)
self.app.post('/?action=login', {'_method': 'HEAD'}, status=405)
def test_initConfig(self):
os.mkdir(os.path.join(self.root, "penguins"))
self.app.get('http://ass2m.test/penguins/', status=200)
storage = Storage.lookup(self.root)
assert storage.get_config().data['web']['root_url'] == 'http://ass2m.test/'
assert storage.get_config().data['web']['cookie_secret']
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment