Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion server.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@ def index():
@app.route('/showSummary',methods=['POST'])
def showSummary():
club = [club for club in clubs if club['email'] == request.form['email']]
other_clubs = [club for club in clubs if club['email'] != request.form['email']]
if len(club):
return render_template('welcome.html',club=club[0],competitions=competitions), 200
return render_template('welcome.html',club=club[0],competitions=competitions, clubs=other_clubs), 200
return render_template('index.html'), 401


Expand Down
11 changes: 11 additions & 0 deletions templates/welcome.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,17 @@ <h3>Competitions:</h3>
<hr />
{% endfor %}
</ul>
<h3>Clubs:</h3>
<ul>
{% for club in clubs%}
<li>
{{club['name']}}<br />
Points: {{club['points']}}</br>
Email: {{club['email']}}
</li>
<hr />
{% endfor %}
</ul>
{%endwith%}

</body>
Expand Down
9 changes: 7 additions & 2 deletions tests/unit_test/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,13 @@

clubs_obj = [
{
"name":"TEST_CLUB",
"email":"TEST_CLUB_EMAIL",
"name":"TEST_CLUB_1",
"email":"TEST_CLUB_EMAIL_1",
"points":"10"
},
{
"name":"TEST_CLUB_2",
"email":"TEST_CLUB_EMAIL_2",
"points":"10"
}
]
Expand Down
9 changes: 7 additions & 2 deletions tests/unit_test/mocks_files/fixture_load.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
{
"clubs":[
{
"name":"TEST_CLUB",
"email":"TEST_CLUB_EMAIL",
"name":"TEST_CLUB_1",
"email":"TEST_CLUB_EMAIL_1",
"points":"9"
},
{
"name":"TEST_CLUB_2",
"email":"TEST_CLUB_EMAIL_2",
"points":"10"
}
],
"competitions": [
Expand Down
13 changes: 11 additions & 2 deletions tests/unit_test/test_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def test_sould_not_purshase_more_than_I_own(self):

def test_sould_not_purshase_more_than_12_places(self):
response = self.client.post('/purchasePlaces', data={
"club": "TEST_CLUB",
"club": "TEST_CLUB_2",
"competition": "TEST_COMPETITION_2",
"places": 13
})
Expand All @@ -49,7 +49,7 @@ def test_sould_not_purshase_more_than_12_places(self):

def test_sould_not_purshase_booking_if_date_passed(self):
response = self.client.post('/purchasePlaces', data={
"club": "TEST_CLUB",
"club": "TEST_CLUB_1",
"competition": "TEST_COMPETITION_1",
"places": 1
})
Expand All @@ -69,3 +69,12 @@ def test_club_points_should_be_reflected_after_booking(self):
})
self.assertEqual(int(club.get('points')), points - places)
self.assertEqual(int(competition.get('numberOfPlaces')), number_of_places - places)

def test_feature_implementation(self):
response = self.client.post("/showSummary", data={'email': self.clubs[0].get('email')})
for i, club in enumerate(self.clubs):
if i != 0:
self.assertIn(club.get("name"), response.data.decode())
self.assertIn(f"Points: {club.get('points')}</br>", response.data.decode())
self.assertIn(f"Email: {club.get('email')}", response.data.decode())
assert response.status_code == 200