Merge lp:~robru/bileto/cleanup-login-endpoint into lp:bileto

Proposed by Robert Bruce Park
Status: Merged
Approved by: Robert Bruce Park
Approved revision: 212
Merged at revision: 211
Proposed branch: lp:~robru/bileto/cleanup-login-endpoint
Merge into: lp:bileto
Diff against target: 50 lines (+15/-2)
3 files modified
tests/test_login.py (+10/-0)
tests/test_sessions.py (+4/-2)
tickets/login.py (+1/-0)
To merge this branch: bzr merge lp:~robru/bileto/cleanup-login-endpoint
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Approve
Robert Bruce Park (community) Approve
Review via email: mp+267213@code.launchpad.net

Commit message

Fix unhandled /login traceback.

Description of the change

This fixes this production traceback:

2015-08-06 15:36:25,831 ERROR Exception on /login [GET]
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/flask/app.py", line 1817, in wsgi_app
    response = self.full_dispatch_request()
  File "/usr/lib/python3/dist-packages/flask/app.py", line 1478, in full_dispatch_request
    response = self.make_response(rv)
  File "/usr/lib/python3/dist-packages/flask/app.py", line 1566, in make_response
    raise ValueError('View function did not return a response')
ValueError: View function did not return a response

Which happens if you GET /login without already being logged in.

To post a comment you must log in.
212. By Robert Bruce Park

Fix test that relies on dict ordering.

Revision history for this message
Robert Bruce Park (robru) wrote :

Looks good in staging.

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'tests/test_login.py'
2--- tests/test_login.py 2015-07-31 17:08:58 +0000
3+++ tests/test_login.py 2015-08-06 16:15:52 +0000
4@@ -10,6 +10,16 @@
5 ), follow_redirects=False)
6 self.assertIn(b'https://localhost/login?next=/</a>.', rv.data)
7
8+ def test_login_get(self):
9+ rv = self.app.get('/login', follow_redirects=False)
10+ self.assertIn(b'<a href="/">/</a>.', rv.data)
11+
12+ def test_logged_already(self):
13+ with self.app.session_transaction() as sesh:
14+ sesh['nickname'] = 'bileto'
15+ rv = self.app.get('/login', follow_redirects=False)
16+ self.assertIn(b'>https://localhost/</a>', rv.data)
17+
18 def test_logout(self):
19 with self.app.session_transaction() as sesh:
20 sesh['foo'] = 'bar'
21
22=== modified file 'tests/test_sessions.py'
23--- tests/test_sessions.py 2015-08-03 06:19:36 +0000
24+++ tests/test_sessions.py 2015-08-06 16:15:52 +0000
25@@ -1,4 +1,4 @@
26-from pickle import dumps
27+from pickle import dumps, loads
28
29 from tests.tests import BiletoTestCase
30
31@@ -29,4 +29,6 @@
32 sesh = PickleSession(app.session_interface.directory, 'grill')
33 sesh['foo'] = 'bar'
34 with open(sesh.path, 'rb') as pickled:
35- self.assertEqual(pickled.read(), dumps(dict(foo='bar', baz='qux')))
36+ self.assertDictEqual(
37+ loads(pickled.read()),
38+ dict(foo='bar', baz='qux'))
39
40=== modified file 'tickets/login.py'
41--- tickets/login.py 2015-08-05 21:21:09 +0000
42+++ tickets/login.py 2015-08-06 16:15:52 +0000
43@@ -16,6 +16,7 @@
44 ask_for=['nickname'],
45 ask_for_optional=['fullname', 'email'],
46 extensions=[Teams])
47+ return redirect('/')
48
49
50 @oid.after_login

Subscribers

People subscribed via source and target branches