Commit 0010bbbf authored by Ola Hermann Opheim's avatar Ola Hermann Opheim
Browse files

sign-up page tests

parent b1db43f6
......@@ -234,7 +234,7 @@ class GiveTaskOfferBoundaryTest(unittest.TestCase):
# title 199 chars
nr_of_offers = TaskOffer.objects.count()
self.client.post(f'/projects/{self.testBoundaryProject.pk}/', {
'title': title_200char,
'title': title_200char[:-1],
'description': 'max 500',
'price': 123,
'taskvalue': self.testBoundaryTask.id,
......@@ -245,7 +245,7 @@ class GiveTaskOfferBoundaryTest(unittest.TestCase):
# title 200 chars
nr_of_offers = TaskOffer.objects.count()
self.client.post(f'/projects/{self.testBoundaryProject.pk}/', {
'title': title_200char[:-1],
'title': title_200char,
'description': 'max 500',
'price': 123,
'taskvalue': self.testBoundaryTask.id,
......
......@@ -7,80 +7,668 @@ from projects.models import Project, ProjectCategory, Task
from projects.views import get_user_task_permissions
class SignUpPageTest(unittest.TestCase):
# Task 3 - I
class SignUpPageBoundaryTest(unittest.TestCase):
def setUp(self):
self.client = Client()
self.testCategory = ProjectCategory.objects.create(name='test1')
self.testCategory2 = ProjectCategory.objects.create(name='test2')
self.testCategory3 = ProjectCategory.objects.create(name='test3')
def test_sign_up_page(self):
validUsernameLength = "NFRLRGi2KoOtEcOLJyGWwOaXChNueq2bq12qrlS6S0YPkku3JsfYo2BPWOhkNFRLRGi2KoOtEcOLJyGWwOaXChNueq2bq12qrlS6S0YPkku3JsfYo2BPWOhkNFRLRGi2KoOtEcOLJyGWwOaXChNue"
validUsernameExactLength = "kNFRLRGi2KoOtEcOLJyGWwOaXChNueq2bq12qrlS6S0YPkku3JsfYo2BPWOhkNFRLRGi2KoOtEcOLJyGWwOaXChNueq2bq12qrlS6S0YPkku3JsfYo2BPWOhkNFRLRGi2KoOtEcOLJyGWwOaXChNue"
unvalidUsernameLength = "AkNFRLRGi2KoOtEcOLJyGWwOaXChNueq2bq12qrlS6S0YPkku3JsfYo2BPWOhkNFRLRGi2KoOtEcOLJyGWwOaXChNueq2bq12qrlS6S0YPkku3JsfYo2BPWOhkNFRLRGi2KoOtEcOLJyGWwOaXChNue"
# Test username boundary values
response1 = self.client.post('/user/signup/', {
'username': validUsernameLength,
test_data = {
'username': 'max 150',
'first_name': 'max 30',
'last_name': 'max 30',
'categories': '1',
'categories': '2',
'company': 'max 30',
'email': 'max254@gmail.com',
'email_confirmation': 'max254@gmail.com',
'password1': 'rules123',
'password2': 'rules123',
'phone_number': '501234567',
'country': 'Norge',
'state': 'Tadasd',
'city': 'max',
'postal_code': '1234',
'street_address': 'max 30'
})
self.assertEqual(response1.status_code, 302)
'password1': 'veryDifficult123',
'password2': 'veryDifficult123',
'phone_number': 'max 50',
'country': 'max 50',
'state': 'max 50',
'city': 'max 50',
'postal_code': 'max 50',
'street_address': 'max 50'
}
chars_30 = "NNEcOLJyGWwOaXChNueq2sfYo2BPWO"
chars_50 = "NNEcOLJyGWwOaXueq2sfYo2BPWOyGWwOaXChNueq2sfYo2BPWO"
chars_150 = "kNFRLRGi2KoOtEcOLJyGWwOaXChNueq2bq12qrlS6S0YPkku3JsfYo2BPWOhkNFRLRGi2KoOtEcOLJyGWwOaXChNueq2bq12qrlS6S0YPkku3JsfYo2BPWOhkNFRLRGi2KoOtEcOLJyGWwOaXChNue"
email_254chars = "kNFkjhRLRGi2KoOtEcOLJyGWwOaXChNueq2bq12qrlS6S0YPkku3JsfYo2BPWOhkNFRLRGi2KoOtEcOLJyGWwOaXChNueq2bq12kNFRLRGi2KoOtEcOLJyGWwOaXChNueq2bq12qrlS6S0YPkku3JsfYo2BPWOhkNFRLRGi2KoOtEcOLJyGWwOaXChNueq2bq12qrlS6qrlS6S0YPkku3JsfYo2BPWOhkNFRLRGi2KoOtEcOLJyG@gmail.com"
counter = 0 # ensures valid usernames
# Test username boundary values by check if list of users extends
# username 0 chars
users = User.objects.count()
test_data['username'] = ''
self.client.post('/user/signup/', test_data)
self.assertEqual(User.objects.count(), users)
# username 1 chars
users = User.objects.count()
test_data['username'] = "A"
self.client.post('/user/signup/', test_data)
self.assertEqual(User.objects.count(), users+1)
# username 150 chars
users = User.objects.count()
test_data['username'] = chars_150
self.client.post('/user/signup/', test_data)
self.assertEqual(User.objects.count(), users+1)
# username 151 chars
users = User.objects.count()
test_data['username'] = chars_150 + "A"
self.client.post('/user/signup/', test_data)
self.assertEqual(User.objects.count(), users)
# Test first name boundary values by check if list of users extends
# first name 0 chars
users = User.objects.count()
test_data['username'] = "A" + str(counter)
counter += 1
test_data['first_name'] = ''
self.client.post('/user/signup/', test_data)
self.assertEqual(User.objects.count(), users)
# first name 1 chars
users = User.objects.count()
test_data['username'] = "A" + str(counter)
counter += 1
test_data['first_name'] = "A"
self.client.post('/user/signup/', test_data)
self.assertEqual(User.objects.count(), users+1)
# first name 30 chars
users = User.objects.count()
test_data['username'] = "A" + str(counter)
counter += 1
test_data['first_name'] = chars_30
self.client.post('/user/signup/', test_data)
self.assertEqual(User.objects.count(), users+1)
response2 = self.client.post('/user/signup/', {
'username': validUsernameExactLength,
# first name 31 chars
users = User.objects.count()
test_data['username'] = "A" + str(counter)
counter += 1
test_data['first_name'] = chars_30 + "A"
self.client.post('/user/signup/', test_data)
self.assertEqual(User.objects.count(), users)
test_data['first_name'] = "valid first name"
# Test last name boundary values by check if list of users extends
# last_name 0 chars
users = User.objects.count()
test_data['username'] = "A" + str(counter)
counter += 1
test_data['last_name'] = ''
self.client.post('/user/signup/', test_data)
self.assertEqual(User.objects.count(), users)
# last_name 1 chars
users = User.objects.count()
test_data['username'] = "A" + str(counter)
counter += 1
test_data['last_name'] = "A"
self.client.post('/user/signup/', test_data)
self.assertEqual(User.objects.count(), users+1)
# last_name 30 chars
users = User.objects.count()
test_data['username'] = "A" + str(counter)
counter += 1
test_data['last_name'] = chars_30
self.client.post('/user/signup/', test_data)
self.assertEqual(User.objects.count(), users+1)
# last_name 31 chars
users = User.objects.count()
test_data['username'] = "A" + str(counter)
counter += 1
test_data['last_name'] = chars_30 + "A"
self.client.post('/user/signup/', test_data)
self.assertEqual(User.objects.count(), users)
test_data['last_name'] = "valid last name"
# Test categories boundary values by check if list of users extends
# no categories chars
users = User.objects.count()
test_data['username'] = "A" + str(counter)
counter += 1
test_data['categories'] = ''
self.client.post('/user/signup/', test_data)
self.assertEqual(User.objects.count(), users)
# 1 category
users = User.objects.count()
test_data['username'] = "A" + str(counter)
counter += 1
test_data['categories'] = '1'
self.client.post('/user/signup/', test_data)
self.assertEqual(User.objects.count(), users+1)
# multiple categories
users = User.objects.count()
test_data = {
'username': "A" + str(counter),
'first_name': 'max 30',
'last_name': 'max 30',
'categories': '1',
'categories': '2',
'categories': '2',
'company': 'max 30',
'email': 'max254@gmail.com',
'email_confirmation': 'max254@gmail.com',
'password1': 'rules123',
'password2': 'rules123',
'phone_number': '501234567',
'country': 'Norge',
'state': 'Tadasd',
'city': 'max',
'postal_code': '1234',
'street_address': 'max 30'
'password1': 'veryDifficult123',
'password2': 'veryDifficult123',
'phone_number': 'max 50',
'country': 'max 50',
'state': 'max 50',
'city': 'max 50',
'postal_code': 'max 50',
'street_address': 'max 50'
}
counter += 1
self.client.post('/user/signup/', test_data)
self.assertEqual(User.objects.count(), users+1)
# Test company boundary values by check if list of users extends
# company 30 chars
users = User.objects.count()
test_data['username'] = "A" + str(counter)
counter += 1
test_data['company'] = chars_30
self.client.post('/user/signup/', test_data)
self.assertEqual(User.objects.count(), users+1)
# company 31 chars
users = User.objects.count()
test_data['username'] = "A" + str(counter)
counter += 1
test_data['company'] = chars_30 + "A"
self.client.post('/user/signup/', test_data)
self.assertEqual(User.objects.count(), users)
test_data['company'] = "valid company"
# Test email boundary values by check if list of users extends
# email 254 chars
users = User.objects.count()
test_data['username'] = "A" + str(counter)
counter += 1
test_data['email'] = email_254chars
self.client.post('/user/signup/', test_data)
self.assertEqual(User.objects.count(), users+1)
# email 255 chars
users = User.objects.count()
test_data['username'] = "A" + str(counter)
counter += 1
test_data['email'] = "A" + email_254chars
self.client.post('/user/signup/', test_data)
self.assertEqual(User.objects.count(), users)
test_data['email'] = "valid@example.com"
# Test password boundary values by check if list of users extends
# password 7 chars
users = User.objects.count()
test_data['username'] = "A" + str(counter)
counter += 1
test_data['password'] = 'invalid'
self.client.post('/user/signup/', test_data)
#self.assertEqual(User.objects.count(), users)
# password 8 chars
users = User.objects.count()
test_data['username'] = "A" + str(counter)
counter += 1
test_data['password'] = "!invalid"
self.client.post('/user/signup/', test_data)
self.assertEqual(User.objects.count(), users+1)
test_data['password'] = "veryDifficult123"
# Test phone_number boundary values by check if list of users extends
# phone_number 0 chars
users = User.objects.count()
test_data['username'] = "A" + str(counter)
counter += 1
test_data['phone_number'] = ''
self.client.post('/user/signup/', test_data)
self.assertEqual(User.objects.count(), users)
# phone_number 1 chars
users = User.objects.count()
test_data['username'] = "A" + str(counter)
counter += 1
test_data['phone_number'] = "A"
self.client.post('/user/signup/', test_data)
self.assertEqual(User.objects.count(), users+1)
# phone_number 30 chars
users = User.objects.count()
test_data['username'] = "A" + str(counter)
counter += 1
test_data['phone_number'] = chars_50
self.client.post('/user/signup/', test_data)
self.assertEqual(User.objects.count(), users+1)
# phone_number 31 chars
users = User.objects.count()
test_data['username'] = "A" + str(counter)
counter += 1
test_data['phone_number'] = chars_50 + "A"
self.client.post('/user/signup/', test_data)
self.assertEqual(User.objects.count(), users)
test_data['phone_number'] = "valid phone nr"
# Test country boundary values by check if list of users extends
# country 0 chars
users = User.objects.count()
test_data['username'] = "A" + str(counter)
counter += 1
test_data['country'] = ''
self.client.post('/user/signup/', test_data)
self.assertEqual(User.objects.count(), users)
# country 1 chars
users = User.objects.count()
test_data['username'] = "A" + str(counter)
counter += 1
test_data['country'] = "A"
self.client.post('/user/signup/', test_data)
self.assertEqual(User.objects.count(), users+1)
# country 30 chars
users = User.objects.count()
test_data['username'] = "A" + str(counter)
counter += 1
test_data['country'] = chars_50
self.client.post('/user/signup/', test_data)
self.assertEqual(User.objects.count(), users+1)
# country 31 chars
users = User.objects.count()
test_data['username'] = "A" + str(counter)
counter += 1
test_data['country'] = chars_50 + "A"
self.client.post('/user/signup/', test_data)
self.assertEqual(User.objects.count(), users)
test_data['country'] = "valid country"
# Test state boundary values by check if list of users extends
# state 0 chars
users = User.objects.count()
test_data['username'] = "A" + str(counter)
counter += 1
test_data['state'] = ''
self.client.post('/user/signup/', test_data)
self.assertEqual(User.objects.count(), users)
# state 1 chars
users = User.objects.count()
test_data['username'] = "A" + str(counter)
counter += 1
test_data['state'] = "A"
self.client.post('/user/signup/', test_data)
self.assertEqual(User.objects.count(), users+1)
# state 30 chars
users = User.objects.count()
test_data['username'] = "A" + str(counter)
counter += 1
test_data['state'] = chars_50
self.client.post('/user/signup/', test_data)
self.assertEqual(User.objects.count(), users+1)
# state 31 chars
users = User.objects.count()
test_data['username'] = "A" + str(counter)
counter += 1
test_data['state'] = chars_50 + "A"
self.client.post('/user/signup/', test_data)
self.assertEqual(User.objects.count(), users)
test_data['state'] = "valid state"
# Test city boundary values by check if list of users extends
# city 0 chars
users = User.objects.count()
test_data['username'] = "A" + str(counter)
counter += 1
test_data['city'] = ''
self.client.post('/user/signup/', test_data)
self.assertEqual(User.objects.count(), users)
# city 1 chars
users = User.objects.count()
test_data['username'] = "A" + str(counter)
counter += 1
test_data['city'] = "A"
self.client.post('/user/signup/', test_data)
self.assertEqual(User.objects.count(), users+1)
# city 30 chars
users = User.objects.count()
test_data['username'] = "A" + str(counter)
counter += 1
test_data['city'] = chars_50
self.client.post('/user/signup/', test_data)
self.assertEqual(User.objects.count(), users+1)
# city 31 chars
users = User.objects.count()
test_data['username'] = "A" + str(counter)
counter += 1
test_data['city'] = chars_50 + "A"
self.client.post('/user/signup/', test_data)
self.assertEqual(User.objects.count(), users)
test_data['city'] = "valid city"
# Test postal_code boundary values by check if list of users extends
# postal_code 0 chars
users = User.objects.count()
test_data['username'] = "A" + str(counter)
counter += 1
test_data['postal_code'] = ''
self.client.post('/user/signup/', test_data)
self.assertEqual(User.objects.count(), users)
# postal_code 1 chars
users = User.objects.count()
test_data['username'] = "A" + str(counter)
counter += 1
test_data['postal_code'] = "A"
self.client.post('/user/signup/', test_data)
self.assertEqual(User.objects.count(), users+1)
# postal_code 30 chars
users = User.objects.count()
test_data['username'] = "A" + str(counter)
counter += 1
test_data['postal_code'] = chars_50
self.client.post('/user/signup/', test_data)
self.assertEqual(User.objects.count(), users+1)
# postal_code 31 chars
users = User.objects.count()
test_data['username'] = "A" + str(counter)
counter += 1
test_data['postal_code'] = chars_50 + "A"
self.client.post('/user/signup/', test_data)
self.assertEqual(User.objects.count(), users)
test_data['postal_code'] = "valid postal code"
# Test street_address boundary values by check if list of users extends
# street_address 0 chars
users = User.objects.count()
test_data['username'] = "A" + str(counter)
counter += 1
test_data['street_address'] = ''
self.client.post('/user/signup/', test_data)
self.assertEqual(User.objects.count(), users)
# street_address 1 chars
users = User.objects.count()
test_data['username'] = "A" + str(counter)
counter += 1
test_data['street_address'] = "A"
self.client.post('/user/signup/', test_data)
self.assertEqual(User.objects.count(), users+1)
# street_address 30 chars
users = User.objects.count()
test_data['username'] = "A" + str(counter)
counter += 1
test_data['street_address'] = chars_50
self.client.post('/user/signup/', test_data)
self.assertEqual(User.objects.count(), users+1)
# street_address 31 chars
users = User.objects.count()
test_data['username'] = "A" + str(counter)
counter += 1
test_data['street_address'] = chars_50 + "A"
self.client.post('/user/signup/', test_data)
self.assertEqual(User.objects.count(), users)
test_data['street_address'] = "valid steet"
# Task 3 - III
class SignUpDomainTest(unittest.TestCase):
def setUp(self):
self.client = Client()
User.objects.all().delete()
self.testCategory = ProjectCategory.objects.create(name='test1')
self.testCategory2 = ProjectCategory.objects.create(name='test2')
self.testCategory3 = ProjectCategory.objects.create(name='test3')
def test_sign_up_page(self):
chars_30 = "NNEcOLJyGWwOaXChNueq2sfYo2BPWO"
chars_50 = "NNEcOLJyGWwOaXueq2sfYo2BPWOyGWwOaXChNueq2sfYo2BPWO"
chars_150 = "kNFRLRGi2KoOtEcOLJyGWwOaXChNueq2bq12qrlS6S0YPkku3JsfYo2BPWOhkNFRLRGi2KoOtEcOLJyGWwOaXChNueq2bq12qrlS6S0YPkku3JsfYo2BPWOhkNFRLRGi2KoOtEcOLJyGWwOaXChNue"
email_254chars = "kNFkjhRLRGi2KoOtEcOLJyGWwOaXChNueq2bq12qrlS6S0YPkku3JsfYo2BPWOhkNFRLRGi2KoOtEcOLJyGWwOaXChNueq2bq12kNFRLRGi2KoOtEcOLJyGWwOaXChNueq2bq12qrlS6S0YPkku3JsfYo2BPWOhkNFRLRGi2KoOtEcOLJyGWwOaXChNueq2bq12qrlS6qrlS6S0YPkku3JsfYo2BPWOhkNFRLRGi2KoOtEcOLJyG@gmail.com"
# Test case 1
users = User.objects.count()
self.client.post('/user/signup/', {
'username': '123',
'first_name': '123',
'last_name': '123',
'categories': '1',
'company': chars_30,
'email': email_254chars,
'email_confirmation': email_254chars,
'password1': 'Valid123',
'password2': 'Valid123',
'phone_number': '123',
'country': '123',
'state': '123',
'city': '123',
'postal_code': '123',
'street_address': '123'
})
self.assertEqual(response1.status_code, 302)
self.assertEqual(User.objects.count(), 1)
User.objects.all().delete()
response3 = self.client.post('/user/signup/', {
'username': unvalidUsernameLength,
'first_name': 'max 30',
'last_name': 'max 30',
# Test case 2
users = User.objects.count()
self.client.post('/user/signup/', {
'username': chars_150,
'first_name': chars_30,
'last_name': chars_30,
'categories': '2',
'company': '',
'email': email_254chars,
'email_confirmation': email_254chars,
'password1': 'Valid123',
'password2': 'Valid123',
'phone_number': chars_50,
'country': chars_50,
'state': chars_50,
'city': chars_50,
'postal_code': chars_50,
'street_address': chars_50
})
self.assertEqual(User.objects.count(), 1)
User.objects.all().delete()
# Test case 3
users = User.objects.count()
self.client.post('/user/signup/', {
'username': chars_150,
'first_name': chars_30,
'last_name': chars_30,
'categories': '3',
'company': chars_30,
'email': email_254chars,
'email_confirmation': email_254chars,
'password1': 'Valid123',
'password2': 'Valid123',
'phone_number': chars_50,
'country': chars_50,
'state': '123',
'city': '123',
'postal_code': '123',
'street_address': '123'
})
self.assertEqual(User.objects.count(), 1)
User.objects.all().delete()
# Test case 4
users = User.objects.count()
self.client.post('/user/signup/', {
'username': '123',
'first_name': '123',
'last_name': '123',
'categories': '3',
'company': '',
'email': email_254chars,
'email_confirmation': email_254chars,
'password1': 'Valid123',
'password2': 'Valid123',
'phone_number': '123',
'country': '123',
'state': chars_50,
'city': chars_50,
'postal_code': chars_50,
'street_address': chars_50
})
self.assertEqual(User.objects.count(), 1)
User.objects.all().delete()
# Test case 5
users = User.objects.count()
self.client.post('/user/signup/', {