Coverage for ivatar/test_static_pages.py: 97%

29 statements  

« prev     ^ index     » next       coverage.py v7.6.9, created at 2024-12-26 00:11 +0000

1# -*- coding: utf-8 -*- 

2""" 

3Test our views in ivatar.ivataraccount.views and ivatar.views 

4""" 

5# pylint: disable=too-many-lines 

6import os 

7import django 

8from django.test import TestCase 

9from django.test import Client 

10from django.urls import reverse 

11from django.contrib.auth.models import User 

12 

13from ivatar.utils import random_string 

14 

15os.environ["DJANGO_SETTINGS_MODULE"] = "ivatar.settings" 

16django.setup() 

17 

18 

19class Tester(TestCase): # pylint: disable=too-many-public-methods 

20 """ 

21 Main test class 

22 """ 

23 

24 client = Client() 

25 user = None 

26 username = random_string() 

27 password = random_string() 

28 email = "%s@%s.%s" % (username, random_string(), random_string(2)) 

29 # Dunno why random tld doesn't work, but I'm too lazy now to investigate 

30 openid = "http://%s.%s.%s/" % (username, random_string(), "org") 

31 

32 def login(self): 

33 """ 

34 Login as user 

35 """ 

36 self.client.login(username=self.username, password=self.password) 

37 

38 def setUp(self): 

39 """ 

40 Prepare for tests. 

41 - Create user 

42 """ 

43 self.user = User.objects.create_user( 

44 username=self.username, 

45 password=self.password, 

46 ) 

47 

48 def test_contact_page(self): 

49 """ 

50 Test contact page 

51 """ 

52 response = self.client.get(reverse("contact")) 

53 self.assertEqual(response.status_code, 200, "no 200 ok?") 

54 

55 def test_description_page(self): 

56 """ 

57 Test description page 

58 """ 

59 response = self.client.get(reverse("description")) 

60 self.assertEqual(response.status_code, 200, "no 200 ok?") 

61 

62 def test_security_page(self): 

63 """ 

64 Test security page 

65 """ 

66 response = self.client.get(reverse("security")) 

67 self.assertEqual(response.status_code, 200, "no 200 ok?")