-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpytest_unit_test.py
303 lines (290 loc) · 24.6 KB
/
pytest_unit_test.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
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
import pytest
from run import app
@pytest.fixture
def client():
app.config['TESTING'] = True
with app.test_client() as client:
yield client
def test_index_page(client):
response = client.get('/')
assert response.status_code == 200
assert (b'<!DOCTYPE html>\n<html lang="en">\n\n <head>\n <meta charset="utf-'
b'8">\n <meta name="description" content="CSA">\n <meta name="'
b'author" content="web warriors">\n <!--Let browser know website is '
b'optimized for mobile-->\n <meta name="viewport" content="width=dev'
b'ice-width, initial-scale=1.0"/>\n\n <!--Import Google Icon Font-->\n'
b' <link href="http://fonts.googleapis.com/icon?family=Material+Icons" '
b'rel="stylesheet">\n <!--Import materialize.css-->\n <link ty'
b'pe="text/css" rel="stylesheet" href="/static/css/materialize.min.css" media'
b'="screen,projection"/>\n\n <link type="text/css" rel="stylesheet" h'
b'ref="/static/css/style.css"/>\n <title>Carrer Planner</title>\n '
b'</head>\n\n <body>\n <div class="slider fullscreen">\n '
b'<ul class="slides">\n <li>\n <img src="s'
b'tatic/images/1.jpg">\n <div class="caption center-alig'
b'n">\n <h1>CSA</h1>\n <h5>Wel'
b'come to your one stop shop for all job postings.</h5>\n '
b' <a class="waves-effect waves-light btn" href="/login-page">Login/Regis'
b'ter</a>\n </div>\n </li>\n '
b' <li>\n <img src="static/images/2.png">\n '
b' <div class="caption left-align">\n <h3>Simpl'
b'e.</h3>\n <h5>Easy interface so you can spend more'
b' time on the important stuff.</h5>\n <a class="wav'
b'es-effect waves-light btn" href="/login-page">Login/Register</a>\n '
b' </div>\n </li>\n <li>\n '
b' <img src="static/images/3.png">\n <div clas'
b's="caption right-align">\n <h3>Oppurtunities.</h3>'
b'\n <h5 class="light grey-text text-lighten-3">Find'
b' Job and Oppurtunities.</h5>\n <a class="waves-eff'
b'ect waves-light btn" href="/login-page">Login/Register</a>\n '
b' </div>\n </li>\n <li>\n '
b' <img src="static/images/4.jpg">\n <div class="cap'
b'tion center-align">\n <h3>Vibrant</h3>\n '
b' <h5 class="light grey-text text-lighten-3">There\'s a little'
b' something for everyone.</h5>\n <a class="waves-ef'
b'fect waves-light btn" href="/login-page">Login/Register</a>\n '
b' </div>\n </li>\n </ul>\n </div'
b'>\n\n <!--Import jQuery before materialize.js-->\n <script ty'
b'pe="text/javascript" src="https://code.jquery.com/jquery-2.1.1.min.js"></scr'
b'ipt>\n <script type="text/javascript" src="/static/js/materialize.'
b'min.js"></script>\n <script type="text/javascript" src="/static/js'
b'/init.js"></script>\n </body>\n</html>') in response.data
def test_login_page(client):
response = client.get('/login-page')
assert response.status_code == 200
assert (b'<!DOCTYPE html>\n<html lang="en">\n\n <head>\n <meta charset="utf-8"'
b'>\n <meta name="description" content="CSA">\n <meta name="author" co'
b'ntent="Web warriors">\n <!--Let browser know website is optimized '
b'for mobile-->\n <meta name="viewport" content="width=device-width,'
b' initial-scale=1.0"/>\n\n <!--Import Google Icon Font-->\n <l'
b'ink href="http://fonts.googleapis.com/icon?family=Material+Icons" rel="style'
b'sheet">\n <!--Import materialize.css-->\n <link type="text/c'
b'ss" rel="stylesheet" href="/static/css/materialize.min.css" media="screen,p'
b'rojection"/>\n <link type="text/css" rel="stylesheet" href="/stati'
b'c/css/style.css"/>\n <title>Login/Register</title>\n </head>\n\n <bod'
b'y class="blue-grey darken-3 white-text">\n <div class="container">\n '
b' <div class="row">\n <div class="col m6">\n\n '
b' <img class="fullscreen responsive-img" src="static/images/5087579.png">'
b'\n </div>\n <div class="col m6">\n <br'
b' /><br /><br />\n <h3>Login</h3>\n <form met'
b'hod="post" action="/login">\n <div class="row">\n '
b' <div class="col s6">\n '
b' <div class="input-field">\n <input '
b'name="login_username" type="text" class="validate">\n '
b' <label for="login_username">Username</label>\n '
b' </div>\n <div class="'
b'input-field">\n <input name="login_pas'
b'sword" type="password" class="validate">\n '
b' <label for="login_password">Password</label>\n '
b' </div>\n </div>\n '
b'</div>\n <div class="row">\n <di'
b'v class="col s12 m12 l12">\n <button class="bt'
b'n waves-effect waves-light" type="submit" name="action">Submit<i class="mate'
b'rial-icons right">send</i>\n </button>\n '
b' </div>\n </div>\n </for'
b'm>\n\t\t\n </div>\n </div>\n <br /><br /><br /><b'
b'r /><br /><br /><hr />\n <div class="row">\n <h3>Registe'
b"r</h3>\n <p>Don't have an account? No sweat.</p>\n \n"
b' <form class="col s12" method="post" action="/register">\n '
b' <div class="row">\n <h5>General Informatio'
b'n</h5>\n <div class="row">\n <di'
b'v class="input-field col s4">\n <input placeho'
b'lder="Username" name="register_username" type="text" class="validate">\n '
b' <label for="register_username">Username</labe'
b'l>\n </div>\n <div class="in'
b'put-field col s4">\n <input placeholder="Passw'
b'ord" name="register_password" type="password" class="validate">\n '
b' <label for="register_password">Password</label>\n '
b' </div>\n <div class="input-fie'
b'ld col s4">\n <input placeholder="Re-Enter Pas'
b'sword" name="register_password2" type="password" class="validate">\n '
b' <label for="register_password">Password</label>\n '
b' </div>\n </div>\n '
b' <div class="row">\n <div class="input-field c'
b'ol s6">\n <input placeholder="First Name" name'
b'="register_firstname" type="text" class="validate">\n '
b' <label for="register_firstname">First Name</label>\n '
b' </div>\n <div class="input-field col s6'
b'">\n <input placeholder="Last Name" name="regi'
b'ster_lastname" type="text" class="validate">\n '
b' <label for="register_lastname">Last Name</label>\n '
b' </div>\n </div>\n <div class="row"'
b'>\n <div class="input-field col s6">\n '
b' <input placeholder="Email Address" name="register_email" type'
b'="text" class="validate">\n <label for="regist'
b'er_email">Email Address</label>\n </div>\n '
b' </div>\n <div class="row">\n '
b' <h5>Address Information</h5>\n <div class='
b'"input-field col s6">\n <input placeholder="St'
b'reet Address" name="register_streetaddress" type="text" class="validate"'
b'>\n <label for="register_streetaddress">Street'
b' Address</label>\n </div>\n '
b'<div class="input-field col s6">\n <input plac'
b'eholder="City" name="register_city" type="text" class="validate">\n '
b' <label for="register_city">City</label>\n '
b' </div>\n <div class="input-field col'
b' s6">\n <input placeholder="State" name="regis'
b'ter_state" type="text" class="validate">\n <la'
b'bel for="register_state">State</label>\n </div>\n '
b' <div class="input-field col s6">\n '
b' <input placeholder="Country" name="register_country" type="text" '
b'class="validate">\n <label for="register_count'
b'ry">Country</label>\n </div>\n '
b' <div class="input-field col s6">\n <input p'
b'laceholder="Zip" name="register_zip" type="text" class="validate">\n '
b' <label for="register_zip">Zip Code</label>\n '
b' </div>\n \n '
b' <div class="input-field col s6">\n <input pl'
b'aceholder="Y/N" name="employer" type="text" class="validate">\n '
b' <label for="employer">Employer</label>\n '
b' </div>\n \n \n '
b' </div>\n\n \n <div class="ro'
b'w">\n <div class="col s12 m12 l12 center-align">\n '
b' <button class="btn waves-effect waves-light" type'
b'="submit" name="action">Submit<i class="material-icons right">send</i>\n '
b' </button>\n </div>\n '
b' </div>\n </div>\n </form>\n '
b' \n </div>\n </div>\n\n <!--Import jQuery before materiali'
b'ze.js-->\n <script type="text/javascript" src="https://code.jquery.com'
b'/jquery-2.1.1.min.js"></script>\n <script type="text/javascript" src="'
b'static/js/materialize.min.js"></script>\n <script type="text/javascrip'
b't" src="static/js/init.js"></script>\n </body>\n</html>') in response.data
def test_logout_page(client):
response = client.get('/logout')
assert response.status_code == 302
assert (b'<!doctype html>\n<html lang=en>\n<title>Redirecting...</title>\n<h1>Redirec'
b'ting...</h1>\n<p>You should be redirected automatically to the target URL'
b': <a href="/index">/index</a>. If not, click the link.\n') in response.data
def test_user_login(client):
response = client.post('/login',
data={'login_username':"test2", 'login_password': "test"})
assert response.status_code == 200
assert ((b'<!DOCTYPE html>\n<html lang="en">\n\n <head>\n <meta charset="utf-8"'
b'>\n <meta name="description" content="CSA">\n <meta name="author" co'
b'ntent="Web warriors">\n <!--Let browser know website is optimized '
b'for mobile-->\n <meta name="viewport" content="width=device-width,'
b' initial-scale=1.0"/>\n\n <!--Import Google Icon Font-->\n <l'
b'ink href="http://fonts.googleapis.com/icon?family=Material+Icons" rel="style'
b'sheet">\n <!--Import materialize.css-->\n <link type="text/c'
b'ss" rel="stylesheet" href="/static/css/materialize.min.css" media="screen,p'
b'rojection"/>\n <link type="text/css" rel="stylesheet" href="/stati'
b'c/css/style.css"/>\n <title>Login/Register</title>\n </head>\n\n <bod'
b'y class="blue-grey darken-3 white-text">\n <div class="container">\n '
b' <div class="row">\n <div class="col m6">\n\n '
b' <img class="fullscreen responsive-img" src="static/images/5087579.png">'
b'\n </div>\n <div class="col m6">\n <br'
b' /><br /><br />\n <h3>Login</h3>\n <form met'
b'hod="post" action="/login">\n <div class="row">\n '
b' <div class="col s6">\n '
b' <div class="input-field">\n <input '
b'name="login_username" type="text" class="validate">\n '
b' <label for="login_username">Username</label>\n '
b' </div>\n <div class="'
b'input-field">\n <input name="login_pas'
b'sword" type="password" class="validate">\n '
b' <label for="login_password">Password</label>\n '
b' </div>\n </div>\n '
b'</div>\n <div class="row">\n <di'
b'v class="col s12 m12 l12">\n <button class="bt'
b'n waves-effect waves-light" type="submit" name="action">Submit<i class="mate'
b'rial-icons right">send</i>\n </button>\n '
b' </div>\n </div>\n </for'
b'm>\n\t\t\n\t\t\t<p class=error style="color:red"> Incorrect username or pas'
b'sword. Please try again. </p>\n\t\t\n </div>\n </div>\n '
b' <br /><br /><br /><br /><br /><br /><hr />\n <div class="ro'
b'w">\n <h3>Register</h3>\n <p>Don\'t have an account? '
b'No sweat.</p>\n \n <form class="col s12" method="pos'
b't" action="/register">\n <div class="row">\n '
b' <h5>General Information</h5>\n <div class="row">\n'
b' <div class="input-field col s4">\n '
b' <input placeholder="Username" name="register_username" type="te'
b'xt" class="validate">\n <label for="register_u'
b'sername">Username</label>\n </div>\n '
b' <div class="input-field col s4">\n <i'
b'nput placeholder="Password" name="register_password" type="password" class="'
b'validate">\n <label for="register_password">Pa'
b'ssword</label>\n </div>\n <d'
b'iv class="input-field col s4">\n <input placeh'
b'older="Re-Enter Password" name="register_password2" type="password" class="v'
b'alidate">\n <label for="register_password">Pas'
b'sword</label>\n </div>\n </div>\n'
b' <div class="row">\n <div class'
b'="input-field col s6">\n <input placeholder="F'
b'irst Name" name="register_firstname" type="text" class="validate">\n '
b' <label for="register_firstname">First Name</label'
b'>\n </div>\n <div class="inp'
b'ut-field col s6">\n <input placeholder="Last N'
b'ame" name="register_lastname" type="text" class="validate">\n '
b' <label for="register_lastname">Last Name</label>\n '
b' </div>\n </div>\n <'
b'div class="row">\n <div class="input-field col s6"'
b'>\n <input placeholder="Email Address" name="r'
b'egister_email" type="text" class="validate">\n '
b' <label for="register_email">Email Address</label>\n '
b' </div>\n </div>\n <div class="row'
b'">\n <h5>Address Information</h5>\n '
b' <div class="input-field col s6">\n <in'
b'put placeholder="Street Address" name="register_streetaddress" type="text" c'
b'lass="validate">\n <label for="register_street'
b'address">Street Address</label>\n </div>\n '
b' <div class="input-field col s6">\n '
b' <input placeholder="City" name="register_city" type="text" class="valida'
b'te">\n <label for="register_city">City</label>'
b'\n </div>\n <div class="inpu'
b't-field col s6">\n <input placeholder="State" '
b'name="register_state" type="text" class="validate">\n '
b' <label for="register_state">State</label>\n '
b' </div>\n <div class="input-field col s6">\n '
b' <input placeholder="Country" name="register_country" t'
b'ype="text" class="validate">\n <label for="reg'
b'ister_country">Country</label>\n </div>\n '
b' <div class="input-field col s6">\n '
b' <input placeholder="Zip" name="register_zip" type="text" class="validate"'
b'>\n <label for="register_zip">Zip Code</label>'
b'\n </div>\n \n '
b' <div class="input-field col s6">\n <i'
b'nput placeholder="Y/N" name="employer" type="text" class="validate">\n '
b' <label for="employer">Employer</label>\n '
b' </div>\n \n \n'
b' </div>\n\n \n <div cl'
b'ass="row">\n <div class="col s12 m12 l12 center-al'
b'ign">\n <button class="btn waves-effect waves-'
b'light" type="submit" name="action">Submit<i class="material-icons right">sen'
b'd</i>\n </button>\n </di'
b'v>\n </div>\n </div>\n </form>'
b'\n \n </div>\n </div>\n\n <!--Import jQuery befor'
b'e materialize.js-->\n <script type="text/javascript" src="https://code'
b'.jquery.com/jquery-2.1.1.min.js"></script>\n <script type="text/javasc'
b'ript" src="static/js/materialize.min.js"></script>\n <script type="tex'
b't/javascript" src="static/js/init.js"></script>\n </body>\n</html>')) in response.data
def test_notifications_page(client):
with client.session_transaction(subdomain='blue') as session:
session['username'] = "test2"
response = client.get('/notifications', subdomain='blue')
assert response.status_code == 200
assert ((b'<!DOCTYPE html>\n<html lang="en">\n\n <head>\n <meta charset="utf-8"'
b'>\n <meta name="description" content="Travel Planner">\n <!--Let'
b' browser know website is optimized for mobile-->\n <meta name="vie'
b'wport" content="width=device-width, initial-scale=1.0"/>\n\n <!--Im'
b'port Google Icon Font-->\n <link href="http://fonts.googleapis.com'
b'/icon?family=Material+Icons" rel="stylesheet">\n <!--Import materi'
b'alize.css-->\n <link type="text/css" rel="stylesheet" href="/stati'
b'c/css/materialize.min.css" media="screen,projection"/>\n\n <link t'
b'ype="text/css" rel="stylesheet" href="/static/css/style.css"/>\n <'
b'link type="text/css" rel="stylesheet" href="/static/css/custom.css"/>\n '
b' <title>Create Activity | test2</title>\n </head>\n\n <body>\n\n '
b'<main>\n <!-- Navigation bar -->\n \n \n \n '
b' <!-- Page Body -->\n <div class="container">\n <di'
b'v class="right-align">\n <p>\n test2\n '
b' </p>\n </div>\n \n\n \n\n<di'
b'v class="row">\n\t<div class="col s12 green-text">\n\t\t<h2>Notifications'
b'</h2> \n\n <br /><br /><br />\n\t</div>\n\t<table class="responsive'
b'-table centered">\n\t\t<thead>\n\t\t\t<tr>\n\t\t\t\t<th>Notifcation List</th'
b'>\n\t\t\t</tr>\n\t\t</thead>\n\t\t<tbody>\n\t\t\t\n\t\t</tbody>\n\t</table>'
b'\n</div>\n\n </div>\n </main>\n\n <!--Import jQuery before ma'
b'terialize.js-->\n <script type="text/javascript" src="https://code.jqu'
b'ery.com/jquery-2.1.1.min.js"></script>\n <script type="text/javascript'
b'" src="/static/js/materialize.min.js"></script>\n <script type="text/j'
b'avascript" src="/static/js/init.js"></script>\n </body>\n</html>')) in response.data
def test_invalid_url(client):
response = client.get('/invalid_url')
assert response.status_code == 404