Commit ae26bf02 authored by Ola Hermann Opheim's avatar Ola Hermann Opheim
Browse files

not working user tests

parent 60ebe21b
import unittest
from django.test import Client
from django.contrib.auth.models import User
from projects.templatetags.project_extras import get_all_taskoffers
from projects.models import Project, ProjectCategory, Task
from test_helpers import delete_test_data
chars_30 = "NNEcOLJyGWwOaXChNueq2sfYo2BPWO"
chars_50 = "NNEcOLJyGWwOaXueq2sfYo2BPWOyGWwOaXChNueq2sfYo2BPWO"
chars_150 = "kNFRLRGi2KoOtEcOLJyGWwOaXChNueq2bq12qrlS6S0YPkku3JsfYo2BPWOhkNFRLRGi2KoOtEcOLJyGWwOaXChNueq2bq12qrlS6S0YPkku3JsfYo2BPWOhkNFRLRGi2KoOtEcOLJyGWwOaXChNue"
email_254chars = "kNFkjhRLRGi2KoOtEcOLJyGWwOaXChNueq2bq12qrlS6S0YPkku3JsfYo2BPWOhkNFRLRGi2KoOtEcOLJyGWwOaXChNueq2bq12kNFRLRGi2KoOtEcOLJyGWwOaXChNueq2bq12qrlS6S0YPkku3JsfYo2BPWOhkNFRLRGi2KoOtEcOLJyGWwOaXChNueq2bq12qrlS6qrlS6S0YPkku3JsfYo2BPWOhkNFRLRGi2KoOtEcOLJyG@gmail.com"
class SignUpBoundaryTest(unittest.TestCase):
def setUp(self):
delete_test_data()
self.client = Client()
self.test_category = ProjectCategory.objects.create(name='Category')
self.test_data = {
'username': 'username',
'first_name': 'firstname',
'last_name': 'lastname',
'categories': '1',
'company': 'company',
'email': 'user@example.com',
'email_confirmation': 'user@example.com',
'password1': 'veryDifficult123',
'password2': 'veryDifficult123',
'phone_number': '987654321',
'country': 'Country',
'state': 'State',
'city': 'City',
'postal_code': '1234',
'street_address': 'Street 1'
}
def tearDown(self):
delete_test_data()
def test_username_boundaries(self):
# username 0 chars
self.test_data['username'] = ''
self.client.post('/user/signup/', self.test_data)
self.assertEqual(User.objects.count(), 0)
# username 1 chars
self.test_data['username'] = "L"
self.client.post('/user/signup/', self.test_data)
self.assertEqual(User.objects.count(), 1)
# username 150 chars
self.test_data['username'] = chars_150
self.client.post('/user/signup/', self.test_data)
self.assertEqual(User.objects.count(), 2)
# username 151 chars
self.test_data['username'] = chars_150 + "A"
self.client.post('/user/signup/', self.test_data)
self.assertEqual(User.objects.count(), 2)
def test_first_name_boundaries(self):
# first name 0 chars
self.test_data['username'] = "A"
self.test_data['first_name'] = ''
self.client.post('/user/signup/', self.test_data)
self.assertEqual(User.objects.count(), 0)
# first name 1 chars
self.test_data['username'] = "B"
self.test_data['first_name'] = "A"
self.client.post('/user/signup/', self.test_data)
self.assertEqual(User.objects.count(), 1)
# first name 150 chars
self.test_data['username'] = "C"
self.test_data['first_name'] = chars_30
self.client.post('/user/signup/', self.test_data)
self.assertEqual(User.objects.count(), 2)
# first name 151 chars
self.test_data['username'] = "D"
self.test_data['first_name'] = chars_30 + "A"
self.client.post('/user/signup/', self.test_data)
self.assertEqual(User.objects.count(), 2)
def test_last_name_boundaries(self):
# last name 0 chars
self.test_data['username'] = "E"
self.test_data['last_name'] = ''
self.client.post('/user/signup/', self.test_data)
self.assertEqual(User.objects.count(), 0)
# last name 1 chars
self.test_data['username'] = "F"
self.test_data['last_name'] = "A"
self.client.post('/user/signup/', self.test_data)
self.assertEqual(User.objects.count(), 1)
# last name 150 chars
self.test_data['username'] = "G"
self.test_data['last_name'] = chars_30
self.client.post('/user/signup/', self.test_data)
self.assertEqual(User.objects.count(), 2)
# last name 151 chars
self.test_data['username'] = "H"
self.test_data['last_name'] = chars_30 + "A"
self.client.post('/user/signup/', self.test_data)
self.assertEqual(User.objects.count(), 2)
"""
def test_categories_boundaries(self):
# no categories
self.test_data['username'] = "A"
self.test_data['categories'] = ''
self.client.post('/user/signup/', self.test_data)
self.assertEqual(User.objects.count(), 0)
# 1 category
self.test_data['username'] = "B"
self.test_data['categories'] = '1'
self.client.post('/user/signup/', self.test_data)
self.assertEqual(User.objects.count(), 1)
# multiple categories
test_category_2 = ProjectCategory.objects.create(name='Category2')
test_data = {
'username': 'C',
'first_name': 'firstname',
'last_name': 'lastname',
'categories': '1',
'categories': '2',
'company': 'company',
'email': 'user@example.com',
'email_confirmation': 'user@example.com',
'password1': 'veryDifficult123',
'password2': 'veryDifficult123',
'phone_number': '987654321',
'country': 'Country',
'state': 'State',
'city': 'City',
'postal_code': '1234',
'street_address': 'Street 1'
}
self.client.post('/user/signup/', test_data)
self.assertEqual(User.objects.count(), 2)
"""
\ No newline at end of file
This diff is collapsed.
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment