forked from NakamotoInstitute/nakamotoinstitute.org
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tests.py
177 lines (163 loc) · 6.08 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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
#
# Satoshi Nakamoto Institute (http://nakamotoinstitute.org)
# Copyright 2013 Satoshi Nakamoto Institute
# Licensed under GNU Affero GPL (https://github.com/pierrerochard/SNI-private/blob/master/LICENSE)
#
import os
import unittest
import config
from config import SERVER_NAME
from sni import app, db
from sni.models import Email, Post, Doc
class TestCase(unittest.TestCase):
#Test Homepages
def test_index(self):
tester = app.test_client(self)
resp = tester.get('/').data
assert "I've been working on" in resp
#Test
resp = tester.get('http://satoshi.'+SERVER_NAME).data
assert "Emails" and "Forum Posts" and "Code" in resp
#Test About Page
def test_about(self):
tester = app.test_client(self)
resp = tester.get('/about').data
assert "Redirecting..." in resp
resp = tester.get('/about/').data
assert "The Satoshi Nakamoto Institute (SNI) was founded in November 2013" in resp
#Test Contact Page
def test_contact(self):
tester = app.test_client(self)
resp = tester.get('/contact').data
assert "Redirecting..." in resp
resp = tester.get('/contact/').data
assert "contact (at) nakamotoinstitute.org" in resp
#Test Email Index
def test_emails(self):
tester = app.test_client(self)
resp = tester.get('/emails/').data
assert "Page Not Found" in resp
resp = tester.get('http://satoshi.'+SERVER_NAME+'/emails').data
assert "Redirecting..." in resp
resp = tester.get('http://satoshi.'+SERVER_NAME+'/emails/').data
assert "Cryptography Mailing List Emails" in resp
resp = tester.get('http://satoshi.'+SERVER_NAME+'/emails/cryptography').data
assert "Redirecting..." in resp
resp = tester.get('http://satoshi.'+SERVER_NAME+'/emails/cryptography/').data
assert "Cryptography Mailing List Emails" in resp
#Test Email View
def test_emailview(self):
tester = app.test_client(self)
resp = tester.get('/emails/1').data
assert "Page Not Found" in resp
resp = tester.get('http://satoshi.'+SERVER_NAME+'/emails/1/').data
assert "Page Not Found" in resp
#Test real email
resp = tester.get('http://satoshi.'+SERVER_NAME+'/emails/cryptography/1').data
assert "Redirecting..." in resp
resp = tester.get('http://satoshi.'+SERVER_NAME+'/emails/cryptography/1/').data
assert "The Cryptography Mailing List" in resp
#Test non-existing email
resp = tester.get('http://satoshi.'+SERVER_NAME+'/emails/cryptography/19').data
assert "Redirecting..." in resp
resp = tester.get('http://satoshi.'+SERVER_NAME+'/emails/cryptography/19/').data
assert "Redirecting..." in resp # Goes back to index
#Test Post Index
def test_posts(self):
tester = app.test_client(self)
resp = tester.get('/posts/').data
assert "Page Not Found" in resp
resp = tester.get('http://satoshi.'+SERVER_NAME+'/posts').data
assert "Redirecting..." in resp
resp = tester.get('http://satoshi.'+SERVER_NAME+'/posts/').data
assert "Forum Posts" in resp
#Test Post View
def test_postview(self):
tester = app.test_client(self)
resp = tester.get('/emails/1').data
assert "Page Not Found" in resp
#Test real post
resp = tester.get('http://satoshi.'+SERVER_NAME+'/posts/1').data
assert "Redirecting..." in resp
resp = tester.get('http://satoshi.'+SERVER_NAME+'/posts/1/').data
assert "Original Post" in resp
#Test non-existing post
resp = tester.get('http://satoshi.'+SERVER_NAME+'/posts/1000').data
assert "Redirecting..." in resp
resp = tester.get('http://satoshi.'+SERVER_NAME+'/posts/1000/').data
assert "Redirecting..." in resp # Goes back to index
#Test Literature index
def test_literature(self):
tester = app.test_client(self)
resp = tester.get('/literature').data
assert "Redirecting..." in resp
resp = tester.get('/literature/').data
assert "Literature" in resp
#Test document info page
def test_docinfo(self):
tester = app.test_client(self)
#Test real doc
resp = tester.get('/literature/1').data
assert "Redirecting..." in resp
resp = tester.get('/literature/1/').data
assert "Date:" and "Formats:" in resp
#Test non-existing doc
resp = tester.get('/literature/1000').data
assert "Redirecting..." in resp
resp = tester.get('/literature/1000/').data
assert "Redirecting..." in resp
#Test document view page
def test_docview(self):
tester = app.test_client(self)
#Test real doc format
resp = tester.get('/literature/1/html').data
assert "Redirecting..." in resp
resp = tester.get('/literature/1/html/').data
assert "A purely peer-to-peer version of electronic cash would allow" in resp
#Test real doc format in static files
resp = tester.get('/literature/1/pdf').data
assert "Redirecting..." in resp
resp = tester.get('/literature/1/pdf/').data
assert "Redirecting..." in resp
#Test fake doc format
resp = tester.get('/literature/1/fake').data
assert "Redirecting..." in resp
resp = tester.get('/literature/1/fake/').data
assert "Redirecting..." in resp
#Test fake doc real format
resp = tester.get('/literature/1000/html').data
assert "Redirecting..." in resp
resp = tester.get('/literature/1000/html/').data
assert "Redirecting..." in resp
resp = tester.get('/literature/1000/pdf').data
assert "Redirecting..." in resp
resp = tester.get('/literature/1000/pdf/').data
assert "Redirecting..." in resp
#Test fake doc fake format
resp = tester.get('/literature/1000/fake').data
assert "Redirecting..." in resp
resp = tester.get('/literature/1000/fake/').data
assert "Redirecting..." in resp
#Test old link rerouting
def test_retroute(self):
tester = app.test_client(self)
#Test real html redirect
resp = tester.get('/bitcoin.html').data
assert "Redirecting..." in resp
#Test real other form redirect
resp = tester.get('/bitcoin.pdf').data
assert "Redirecting..." in resp
#Test real slug fake format
resp = tester.get('/bitcoin.fake').data
assert "Redirecting..." in resp
#Test fake html
resp = tester.get('/fake-slug.html').data
assert "Redirecting..." in resp
#Test fake other format
resp = tester.get('/fake-slug.pdf').data
assert "Redirecting..." in resp
#Test fake and fake format
resp = tester.get('/fake-slug.fake').data
assert "Redirecting..." in resp
if __name__ == '__main__':
unittest.main()