-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_registration.py
More file actions
38 lines (33 loc) · 1.03 KB
/
test_registration.py
File metadata and controls
38 lines (33 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import django.urls
import rest_framework.status
import rest_framework.test
import user.models
class RegistrationTests(rest_framework.test.APITestCase):
def setUp(self):
self.client = rest_framework.test.APIClient()
super().setUp()
def tearDown(self):
user.models.User.objects.all().delete()
super().tearDown()
def test_valid_registration(self):
valid_data = {
'name': 'Emma',
'surname': 'Thompson',
'email': 'example@gmail.com',
'password': 'SuperStrongPassword2000!',
'other': {'age': 23, 'country': 'us'},
}
response = self.client.post(
django.urls.reverse('api-user:sign-up'),
valid_data,
format='json',
)
self.assertEqual(
response.status_code,
rest_framework.status.HTTP_200_OK,
)
self.assertTrue(
user.models.User.objects.filter(
email='example@gmail.com',
).exists(),
)