1
+ import server
1
2
from server import loadCompetitions , loadClubs
2
3
3
4
4
5
def test_purchase_places (client ):
5
-
6
6
test_club = loadClubs ()[0 ]
7
7
test_competition = loadCompetitions ()[0 ]
8
8
places_to_purchase = 8
@@ -18,7 +18,6 @@ def test_purchase_places(client):
18
18
19
19
20
20
def test_max_purchase_places (client ):
21
-
22
21
test_club = loadClubs ()[0 ]
23
22
test_competition = loadCompetitions ()[0 ]
24
23
places_to_purchase = 28
@@ -34,7 +33,6 @@ def test_max_purchase_places(client):
34
33
35
34
36
35
def test_has_sufficient_points (client ):
37
-
38
36
test_club = loadClubs ()[1 ]
39
37
test_competition = loadCompetitions ()[0 ]
40
38
places_to_purchase = 9
@@ -47,3 +45,24 @@ def test_has_sufficient_points(client):
47
45
48
46
assert response .status_code == 200
49
47
assert b'Insufficiant points.' in response .data
48
+
49
+
50
+ def test_purchase_places (client , test_clubs , test_competitions , mocker ):
51
+
52
+ mocker .patch ('server.loadClubs' , return_value = test_clubs )
53
+ mocker .patch ('server.loadCompetitions' , return_value = test_competitions )
54
+ mock_save_club = mocker .patch ('server.saveClub' )
55
+
56
+ mocker .patch .object (server , 'clubs' , test_clubs )
57
+ mocker .patch .object (server , 'competitions' , test_competitions )
58
+
59
+ places_to_purchase = 9
60
+
61
+ response = client .post ('/purchasePlaces' , data = {
62
+ 'club' : test_clubs [0 ]['name' ],
63
+ 'competition' : test_competitions [0 ]['name' ],
64
+ 'places' : str (places_to_purchase )
65
+ })
66
+
67
+ assert int (test_clubs [0 ]['points' ]) == 4
68
+ assert b'Great-booking complete!' in response .data
0 commit comments