Commit 60cf35d28b293d59dd66115207093fab0de93261
1 parent
c266643909
Exists in
master
fixed up login tests
Showing 1 changed file with 16 additions and 1 deletions Side-by-side Diff
flashcards/tests/test_api.py
View file @
60cf35d
... | ... | @@ -5,13 +5,26 @@ |
5 | 5 | |
6 | 6 | class LoginTests(APITestCase): |
7 | 7 | def setUp(self): |
8 | - User.objects.create(email="test@flashy.cards", password='1234') | |
8 | + email = "test@flashy.cards" | |
9 | + User.objects.create_user(email, email=email, password="1234") | |
9 | 10 | |
10 | 11 | def test_login(self): |
11 | 12 | url = '/api/login' |
12 | 13 | data = {'email': 'test@flashy.cards', 'password': '1234'} |
13 | 14 | response = self.client.post(url, data, format='json') |
14 | 15 | self.assertEqual(response.status_code, HTTP_200_OK) |
16 | + | |
17 | + data = {'email': 'test@flashy.cards', 'password': '54321'} | |
18 | + response = self.client.post(url, data, format='json') | |
19 | + self.assertContains(response, 'Invalid email or password', status_code=400) | |
20 | + | |
21 | + data = {'email': 'none@flashy.cards', 'password': '54321'} | |
22 | + response = self.client.post(url, data, format='json') | |
23 | + self.assertContains(response, 'Invalid email or password', status_code=400) | |
24 | + | |
25 | + data = {'password': '54321'} | |
26 | + response = self.client.post(url, data, format='json') | |
27 | + self.assertContains(response, 'Email is required', status_code=400) | |
15 | 28 | |
16 | 29 | |
17 | 30 | class RegistrationTest(APITestCase): |