Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

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

39

40

41

from ..forms import CustomUserCreationForm, EditUser 

from django.test import TestCase 

from datetime import date 

 

 

class CustomUserCreationFormTests(TestCase): 

 

def test_valid_form(self): 

data = {'name_surname': "Testing test", 'username': "testinguser", 

'email': 'test@test.com', 'country': 'US', 

'date_of_birth': '1997-07-08', 'password1': 'A1.aaaaa', 

'password2': 'A1.aaaaa'} 

form = CustomUserCreationForm(data=data) 

self.assertTrue(form.is_valid()) 

 

def test_invalid_birthday_form(self): 

data = {'name_surname': "Testing test", 'username': "testinguser", 

'email': 'test@test.com', 'country': 'US', 

'date_of_birth': date.today(), 'password1': 'A1.aaaaa', 

'password2': 'A1.aaaaa'} 

form = CustomUserCreationForm(data=data) 

self.assertFalse(form.is_valid()) 

 

 

class EditUserCreationFormTests(TestCase): 

 

def test_valid_form(self): 

data = {'name_surname': "Testing test", 'country': 'US', 

'date_of_birth': '1997-07-08', 'gender': 'f', 

'email': 'newEmail@gm.com', 

'website': 'good-url', 'about_me': "blah blah"} 

form = EditUser(data=data) 

self.assertTrue(form.is_valid()) 

 

def test_invalid_country_form(self): 

data = {'name_surname': "Testing test", 'country': 'invalid-country', 

'email': 'newEmail@gm.com', 

'date_of_birth': '1997-07-08', 'gender': 'f', 

'website': 'good-url', 'about_me': "blah blah"} 

form = EditUser(data=data) 

self.assertFalse(form.is_valid())