This repository has been archived by the owner on May 30, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtests.py
124 lines (87 loc) · 3.39 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
from django.test.client import Client
import unittest
class MingusClientTests(unittest.TestCase):
def setUp(self):
pass
def tearDown(self):
pass
def test_HomePage(self):
'''Test if the homepage renders.'''
c = Client()
response = c.get('/')
self.failUnlessEqual(response.status_code, 200)
def test_Homepage_Paging(self):
'''
Test paging the homepage list.
'''
#need to update blog Settings page size, it defaults to 20 but we
#don't have 20 records to page. So we'll set it to 1 and we should be ok.
from basic.blog.models import Settings
settings = Settings.get_current()
settings.page_size = 1
settings.save()
c = Client()
response = c.get('/', {'page': 2},)
self.failUnlessEqual(response.status_code, 200)
def test_Search(self):
'''Test search view.'''
c = Client()
response = c.get('/search/', {'q':'django'})
#test success request
self.failUnlessEqual(response.status_code, 200)
#test result as expected
self.assertEquals(response.context['object_list'][0].title, 'django-mingus forked #sitesprint')
def test_About(self):
'Test if the about page renders.'
c = Client()
response = c.get('/about/')
self.failUnlessEqual(response.status_code, 200)
def test_Contact(self):
'Test if the contact page renders.'
c = Client()
response = c.get('/contact/')
self.failUnlessEqual(response.status_code, 200)
def test_ContactSubmit(self):
'''
Test submitting the contact form. Expect to return to the form sent
template.
The field 'fonzie_kungfu' is the honeypot field to protect you from
spam. This feature is provided by django-honeypot.
'''
c = Client()
response = c.post('/contact/', {'name': 'charles',
'email': '[email protected]', 'body': 'hello.',
'fonzie_kungfu': ''},
follow=True)
self.failUnlessEqual(response.status_code, 200)
def test_ContactSubmit_WithHoneyPot(self):
'''Test the @honeypot decorator which exists to reduce spam.
HoneyPot will return a 400 response if the honeypot field is
submited with a value.
'''
c = Client()
response = c.post('/contact/', {'name': 'charles', 'email':
'[email protected]', 'body': 'hello.', 'fonzie_kungfu': 'evil'},
follow=True)
self.failUnlessEqual(response.status_code, 400)
def test_RSS(self):
'''Test the latest posts feed displays.'''
c = Client()
response = c.get('/feeds/latest/')
self.failUnlessEqual(response.status_code, 200)
def test_SpringsteenFeed_Posts(self):
'''
Test the latest Post springsteen feed for findjango integration
displays.
'''
c = Client()
response = c.get('/api/springsteen/posts/')
self.failUnlessEqual(response.status_code, 200)
def test_SpringsteenFeed_Posts_ByCategory(self):
'''
Test the latest Post By Category springsteen feed for findjango
integration displays.
'''
c = Client()
response = c.get('/api/springsteen/category/django/')
self.failUnlessEqual(response.status_code, 200)