diff --git a/server.py b/server.py index 0e21b7c48..fbab634cd 100644 --- a/server.py +++ b/server.py @@ -49,6 +49,10 @@ def purchasePlaces(): club = [c for c in clubs if c['name'] == request.form['club']][0] placesRequired = int(request.form['places']) + if placesRequired > 12: + flash('You cannot required more than 12 places!') + return render_template('welcome.html', club=club, competitions=competitions), 403 + if placesRequired > int(club.get("points")): flash('You haven\'t enough of points to purshase this!') return render_template('welcome.html', club=club, competitions=competitions), 403 diff --git a/tests/unit_test/conftest.py b/tests/unit_test/conftest.py index c66721c19..0f1f5ca7c 100644 --- a/tests/unit_test/conftest.py +++ b/tests/unit_test/conftest.py @@ -9,7 +9,7 @@ def get_clubs(): { "name":"TEST_CLUB", "email":"TEST_CLUB_EMAIL", - "points":"13" + "points":"10" } ] diff --git a/tests/unit_test/mocks_files/fixture_load.json b/tests/unit_test/mocks_files/fixture_load.json index 1d724612b..b6f88b6a8 100644 --- a/tests/unit_test/mocks_files/fixture_load.json +++ b/tests/unit_test/mocks_files/fixture_load.json @@ -3,7 +3,7 @@ { "name":"TEST_CLUB", "email":"TEST_CLUB_EMAIL", - "points":"13" + "points":"10" } ], "competitions": [ diff --git a/tests/unit_test/test_server.py b/tests/unit_test/test_server.py index 97fe9e0c6..ceae4e522 100644 --- a/tests/unit_test/test_server.py +++ b/tests/unit_test/test_server.py @@ -35,7 +35,16 @@ def test_sould_not_purshase_more_than_I_own(self): "competition": com.get('name'), "places": int(cl.get('points')) + 1 } - + response = self.client.post('/purchasePlaces', data=mock) self.assertIn("You haven't enough of points to purshase this!", response.data.decode()) self.assertEqual(response.status_code, 403) + + def test_sould_not_purshase_more_than_12_places(self): + response = self.client.post('/purchasePlaces', data={ + "club": "TEST_CLUB", + "competition": "TEST_COMPETITION", + "places": 13 + }) + self.assertIn("You cannot required more than 12 places!", response.data.decode()) + self.assertEqual(response.status_code, 403)