8000 Add register -> login system test. · SWCodeG/testing-python-apps@178f6fc · GitHub
[go: up one dir, main page]

Skip to content

Commit 178f6fc

Browse files
committed
Add register -> login system test.
1 parent c78f381 commit 178f6fc

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

section4/video_code/tests/system/user_test.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,17 @@ def test_register_user(self):
1414
self.assertDictEqual(d1={'message': 'User created successfully.'},
1515
d2=json.loads(r.data))
1616

17+
def test_register_and_login(self):
18+
with self.app() as c:
19+
with self.app_context():
20+
c.post('/register', data={'username': 'test', 'password': '1234'})
21+
auth_request = c.post('/auth', data=json.dumps({
22+
'username': 'test',
23+
'password': '1234'
24+
}), headers={'Content-Type': 'application/json'})
25+
26+
self.assertIn('access_token', json.loads(auth_request.data).keys())
27+
1728
def test_register_duplicate_user(self):
1829
with self.app() as c:
1930
with self.app_context():

0 commit comments

Comments
 (0)
0