-
Notifications
You must be signed in to change notification settings - Fork 140
/
tests.py
84 lines (77 loc) · 2.84 KB
/
tests.py
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
from django.test import TestCase, override_settings
from django.urls import reverse
@override_settings(ROOT_URLCONF=__name__[:-5] + "config.urls")
class Test(TestCase): # noqa: D101
fixtures = ["users.json"]
def setUp(self): # noqa: D102
self.assertTrue(self.client.login(username="admin", password="admin"))
def test_checkout_form(self):
form_url = reverse("forms:checkout_form")
response = self.client.get(form_url)
self.assertEqual(response.status_code, 200)
response = self.client.post(
form_url,
{
"first_name": "John",
"last_name": "Doe",
"email": "[email protected]",
"phone": "3727992222",
"country": "16",
"city": "Tallinn", # todo validation
"post_code": "15169",
"address": "Ravel 5",
"additional_info": "Estonian Informatics Center",
"card_type": "V",
"card_holder": "JOHN DOE",
"card_number": "4111111111111111",
"card_ccv2": "000",
"card_exp_month": "1",
"card_exp_year": "2024",
},
)
self.assertEqual(response.status_code, 302)
def test_contact_form(self):
form_url = reverse("forms:contact_form")
response = self.client.get(form_url)
self.assertEqual(response.status_code, 200)
response = self.client.post(
form_url,
{
"name": "John Doe",
"email": "[email protected]",
"subject": "What's up!",
"message": "Hey!",
"send_copy": 1,
},
)
self.assertEqual(response.status_code, 302)
def test_login_form(self):
form_url = reverse("forms:login_form")
response = self.client.get(form_url)
self.assertEqual(response.status_code, 200)
response = self.client.post(
form_url,
{
"email": "[email protected]",
"password": "test123456",
},
)
self.assertEqual(response.status_code, 302)
def test_profile_form(self):
form_url = reverse("forms:profile_form")
response = self.client.get(form_url)
self.assertEqual(response.status_code, 200)
response = self.client.post(
form_url,
{
"username": "john_doe",
"first_name": "John",
"last_name": " Doe",
"form-address-line_1": "7945 Durham St.",
"form-address-line_2": "--",
"form-address-state": "FL",
"form-address-city": "Saint Augustine",
"form-address-zipcode": "32084",
},
)
self.assertEqual(response.status_code, 302)