-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.py
106 lines (92 loc) · 3.72 KB
/
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
from main import app
import unittest
import json
class FlaskTestCase(unittest.TestCase):
#Ensure all pages load and behave correctly
#index page
def test_index (self):
tester = app.test_client(self)
response = tester.get('/index', content_type='html/text')
self.assertEqual(response.status_code,200)
print("Index Page Loaded Correctly")
#home page
def test_home (self):
tester = app.test_client(self)
response = tester.get('/home', content_type='html/text')
self.assertEqual(response.status_code,200)
print("Home Page Loaded Correctly")
#about page
def test_about (self):
tester = app.test_client(self)
response = tester.get('/about', content_type='html/text')
self.assertEqual(response.status_code,200)
print("About Page Loaded Correctly")
# games page
def test_games (self):
tester = app.test_client(self)
response = tester.get('/games', content_type='html/text')
self.assertEqual(response.status_code,200)
print("Games Page Loaded Correctly")
#editgames page
def test_editgames (self):
tester = app.test_client(self)
response = tester.get('/editgames', content_type='html/text')
self.assertEqual(response.status_code,200)
print("Edit Games Page Loaded Correctly")
# Test to see if a single game details page loads correctly
def test_single_games (self):
tester = app.test_client(self)
response = tester.get('/grand-theft-auto-v', content_type='html/text')
self.assertEqual(response.status_code,200)
print("GTAV Game Page Loaded Correctly")
# # account page
def test_account (self):
tester = app.test_client(self)
response = tester.get('/account', content_type='html/text')
self.assertEqual(response.status_code,200)
print("Account Page Loaded Correctly")
# def test_add_game (self):
tester = app.test_client(self)
response = tester.post("/games",
data=dict(
gameSlug="unit-test-game",
gameName="Unit Test Game",
gameReleaseDate="2000-01-01",
gameRating=1,
gameImage="https://images7.alphacoders.com/821/thumb-1920-821837.jpg",
gamePrice="44.99",
gameDescription="Test Description"
),
follow_redirects=True)
self.assertEqual(response.status_code,200)
print("Test Game has been added")
#Game Deleted Correctly
def test_delete_game (self):
tester = app.test_client(self)
response = tester.delete("/deleteGame/<slug>",
data=dict(
slug="unit-test-game",
),
follow_redirects=True)
self.assertEqual(response.status_code,200)
print("Game deleted successfully!")
#Basket Loaded Correctly
def test_basket (self):
tester = app.test_client(self)
response = tester.get('/basket', content_type='html/text')
self.assertEqual(response.status_code,200)
print("Basket Page Loaded successfully!")
#MyOrders Loaded Correctly
def test_myOrders (self):
tester = app.test_client(self)
response = tester.get('/myOrders', content_type='html/text')
self.assertEqual(response.status_code,200)
print("Orders Page Loaded successfully!")
#Account Info Loaded Correctly
def test_accountInfo (self):
tester = app.test_client(self)
response = tester.get('/accountInfo', content_type='html/text')
self.assertEqual(response.status_code,200)
print("Acccount Info Page Loaded successfully!")
if __name__ == "__main__":
unittest.main()