-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtests.py
127 lines (91 loc) · 4.12 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
"""Test for Nautical Tour's Flask app."""
import unittest
from server import app
from flask import session
from model import connect_to_db, db
class NauticalTests(unittest.TestCase):
"""Tests for my nautical site"""
def setUp(self):
"""Code to run before every test."""
self.client = app.test_client()
app.config['TESTING'] = True
# Connect to test database
connect_to_db(app)
def test_home_page(self):
"""Confirmation that home page loads"""
result = self.client.get("/")
self.assertEqual(result.status_code, 200)
self.assertIn(b"Nautical", result.data)
def test_tour_page(self):
"""Confirmation that tour page loads"""
result = self.client.get("/tours")
self.assertEqual(result.status_code, 200)
self.assertIn(b"Hawaii", result.data)
def test_about(self):
"""Confirmation that about loads"""
result = self.client.get("/about")
self.assertEqual(result.status_code, 200)
self.assertIn(b"<!-- Sendgrid (Twilio) form-->", result.data)
def test_login(self):
"""Test login page"""
result = self.client.post("/login",
data={"email": "[email protected]", "password": "blue"},
follow_redirects=True)
self.assertEqual(result.status_code, 200)
self.assertIn(b"Tour Information", result.data)
def test_sign_up(self):
"""Test Sign-Up Page"""
result = self.client.post("/users", data={
"fname": "Pear",
"lname": "Blu",
"email": "[email protected]",
"password": "blue",
"phone": "555-555-5555",
"birthday": "1990-01-01"
}, follow_redirects=False)
self.assertEqual(result.status_code, 200)
self.assertIn(b"Account Login", result.data)
def test_logout(self):
"""Test Log out functions"""
result = self.client.post('/logout')
self.assertEqual(result.status_code, 302)
self.assertIn(b"Redirecting", result.data)
def test_tours(self):
"""Test departments page"""
result = self.client.get("/tours/1")
self.assertEqual(result.status_code, 200)
self.assertIn(b"Arctic Winds", result.data)
def test_profile_page(self):
"""Test profile page"""
result = self.client.post("/login",
data={"email": "[email protected]", "password": "blue"},
follow_redirects=True)
self.assertEqual(result.status_code, 200)
self.assertIn(b"Balance", result.data)
self.assertIn(b"Phone", result.data)
def test_review_form(self):
"""Test Review Form"""
with self.client as current:
with current.session_transaction() as period:
period['primary_key'] = 3
period['tour_id']=4
period['dates']='2019-06-29'
result =self.client.post('/review_submission',
data={
"star": "5",
"comments": "Super excited to see the all the Whales on the second day! Incredible glacial Views! Great crew.",
})
self.assertEqual(result.status_code, 200)
self.assertIn(b"Balance", result.data)
def test_review_page(self):
"""Test Review Page"""
result = self.client.get('/review/1')
self.assertEqual(result.status_code, 200)
self.assertIn(b'Overall experience (rating)', result.data)
def test_google_map(self):
"""Test Google Map Api call will be correct"""
result = self.client.get("/tours/1")
self.assertEqual(result.status_code, 200)
self.assertIn(b'<div id="map" class="alaska">', result.data)
if __name__ == "__main__":
unittest.main()