add unhappy day registration test cases
This commit is contained in:
parent
0985e56940
commit
c8422e9ba5
|
@ -3,12 +3,9 @@ from rest_framework import status
|
||||||
from rest_framework.test import APITestCase
|
from rest_framework.test import APITestCase
|
||||||
from apiserver.api.models import Member, User
|
from apiserver.api.models import Member, User
|
||||||
import json
|
import json
|
||||||
|
from parameterized import parameterized
|
||||||
|
|
||||||
class RegistrationTests(APITestCase):
|
data = {
|
||||||
def setUp(self):
|
|
||||||
self.url = reverse('rest_name_register')
|
|
||||||
# TODO: expose data to be used for E2E testing from a webclient
|
|
||||||
self.data = {
|
|
||||||
"username": "registrationtc",
|
"username": "registrationtc",
|
||||||
"email": "unittest@email.com",
|
"email": "unittest@email.com",
|
||||||
"password1": "unittest",
|
"password1": "unittest",
|
||||||
|
@ -19,6 +16,13 @@ class RegistrationTests(APITestCase):
|
||||||
# need to fake this for updating progress
|
# need to fake this for updating progress
|
||||||
"request_id": "lol"
|
"request_id": "lol"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
class RegistrationTests(APITestCase):
|
||||||
|
def setUp(self):
|
||||||
|
self.url = reverse('rest_name_register')
|
||||||
|
# TODO: expose data to be used for E2E testing from a webclient
|
||||||
|
self.data = data
|
||||||
# TODO: match with config
|
# TODO: match with config
|
||||||
self.allowed_ip = '24.66.110.96'
|
self.allowed_ip = '24.66.110.96'
|
||||||
|
|
||||||
|
@ -44,3 +48,16 @@ class RegistrationTests(APITestCase):
|
||||||
HTTP_X_REAL_IP="0.0.0.0"
|
HTTP_X_REAL_IP="0.0.0.0"
|
||||||
)
|
)
|
||||||
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
|
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
|
||||||
|
|
||||||
|
@parameterized.expand([(f"{key} is missing", key, status.HTTP_400_BAD_REQUEST) for key in data.keys() if key is not 'request_id'])
|
||||||
|
def test_malformed_data(self, name, inp, expected):
|
||||||
|
"""Delete specific properties from data and confirm it is not accepted by API"""
|
||||||
|
copy = self.data.copy()
|
||||||
|
del copy[inp]
|
||||||
|
response = self.client.post(
|
||||||
|
self.url,
|
||||||
|
copy,
|
||||||
|
format='json',
|
||||||
|
HTTP_X_REAL_IP=self.allowed_ip
|
||||||
|
)
|
||||||
|
self.assertEqual(response.status_code, expected)
|
||||||
|
|
|
@ -31,6 +31,7 @@ MarkupSafe==1.1.1
|
||||||
matplotlib-inline==0.1.3
|
matplotlib-inline==0.1.3
|
||||||
oauthlib==3.1.0
|
oauthlib==3.1.0
|
||||||
packaging==20.0
|
packaging==20.0
|
||||||
|
parameterized==0.8.1
|
||||||
parso==0.8.3
|
parso==0.8.3
|
||||||
pexpect==4.8.0
|
pexpect==4.8.0
|
||||||
pickleshare==0.7.5
|
pickleshare==0.7.5
|
||||||
|
|
Loading…
Reference in New Issue
Block a user