Commit 45e73561 authored by Remi Rampin's avatar Remi Rampin

Fix tests

parent c7097453
Pipeline #65778850 passed with stage
in 2 minutes and 7 seconds
......@@ -181,11 +181,12 @@ class BaseHandler(RequestHandler):
self.get_cookie('user')):
return super(BaseHandler, self).set_cookie(name, value, **kwargs)
else:
return self.redirect(
self.redirect(
self.reverse_url('cookies_prompt') +
'?' +
urlencode(dict(next=self.request.uri)),
)
raise HTTPError(302)
def get_user_locale(self):
if self.current_user is not None:
......
......@@ -218,6 +218,7 @@ class TestMultiuser(MyHTTPTestCase):
DATABASE=DATABASE_URI,
EMAIL='test@example.com',
MAIL_SERVER={'host': 'localhost', 'port': 25},
COOKIES_PROMPT=True,
MULTIUSER=True,
SECRET_KEY='2PbQ/5Rs005G/nTuWfibaZTUAo3Isng3QuRirmBK',
))
......@@ -242,6 +243,17 @@ class TestMultiuser(MyHTTPTestCase):
for user in db.query(database.User).all()],
['admin'])
# Fetch registration page, should hit cookies prompt
response = self.get('/register')
self.assertEqual(response.code, 302)
self.assertEqual(response.headers['Location'],
'/cookies?next=%2Fregister')
# Accept cookies
response = self.post('/cookies', dict(next='/register'))
self.assertEqual(response.code, 302)
self.assertEqual(response.headers['Location'], '/register')
# Fetch registration page
response = self.get('/register')
self.assertEqual(response.code, 200)
......@@ -293,6 +305,11 @@ class TestMultiuser(MyHTTPTestCase):
@gen_test
async def test_projects(self):
# Accept cookies
response = await self.apost('/cookies', dict())
self.assertEqual(response.code, 302)
self.assertEqual(response.headers['Location'], '/')
# Log in
response = await self.aget('/login')
self.assertEqual(response.code, 200)
......@@ -439,6 +456,7 @@ class TestSingleuser(MyHTTPTestCase):
DATABASE=DATABASE_URI,
EMAIL='test@example.com',
MAIL_SERVER={'host': 'localhost', 'port': 25},
COOKIES_PROMPT=False,
MULTIUSER=False,
SECRET_KEY='bq7ZoAtO7LtRJJ4P0iHSdH8yvcmCqynfeGB+x9y1',
),
......
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