Compare commits
7 Commits
bug/issue6
...
a734f66f22
| Author | SHA1 | Date | |
|---|---|---|---|
| a734f66f22 | |||
| 97019fb223 | |||
| 5ba0e4aecf | |||
| 9e3e049535 | |||
| 811c635a47 | |||
| db692a068e | |||
| 2dc85f19e7 |
12
README.md
12
README.md
@@ -43,9 +43,15 @@
|
|||||||
* clubs.json - list of clubs with relevant information. You can look here to see what email addresses the app will accept for login.
|
* clubs.json - list of clubs with relevant information. You can look here to see what email addresses the app will accept for login.
|
||||||
|
|
||||||
5. Testing
|
5. Testing
|
||||||
|
- unit and integration tests :
|
||||||
|
|
||||||
You are free to use whatever testing framework you like-the main thing is that you can show what tests you are using.
|
All tests are made with Pytest, except <code>test_book_old.py</code> which uses Ward
|
||||||
|
Run the tests by using : `pytest -s -v --cov=. --ignore=tests/test_book_old.py`
|
||||||
|
You'll see the result, the list and the coverage rapport
|
||||||
|
|
||||||
We also like to show how well we're testing, so there's a module called
|
you can also run `ward` from the root folder to see the two ward tests
|
||||||
[coverage](https://coverage.readthedocs.io/en/coverage-5.1/) you should add to your project.
|
- performance tests :
|
||||||
|
|
||||||
|
run the app : `FLASK_APP=server.py flask run`
|
||||||
|
then run `locust -f tests/performance_test/locustfile.py` from the root directory and connect with browser to `
|
||||||
|
http://0.0.0.0:8089` and launch tests from the web interface
|
||||||
|
|||||||
@@ -84,7 +84,9 @@ def purchasePlaces():
|
|||||||
competitions=competitions, now=now)
|
competitions=competitions, now=now)
|
||||||
|
|
||||||
# TODO: Add route for points display
|
# TODO: Add route for points display
|
||||||
|
@app.route('/points')
|
||||||
|
def displayPoints():
|
||||||
|
return render_template('points.html', clubs=clubs)
|
||||||
|
|
||||||
@app.route('/logout')
|
@app.route('/logout')
|
||||||
def logout():
|
def logout():
|
||||||
|
|||||||
@@ -22,5 +22,6 @@
|
|||||||
<input type="email" name="email" id=""/>
|
<input type="email" name="email" id=""/>
|
||||||
<button type="submit">Enter</button>
|
<button type="submit">Enter</button>
|
||||||
</form>
|
</form>
|
||||||
|
<a href="{{ url_for('displayPoints') }}">Board of points</a>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
19
templates/points.html
Normal file
19
templates/points.html
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Board of clubs and points || GUDLFT</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h2>Current points</h2>
|
||||||
|
<ul>
|
||||||
|
{% for club in clubs %}
|
||||||
|
<li><strong>club : </strong> {{club['name']}} </br>
|
||||||
|
<strong>Points : </strong>{{club['points']}}</br>
|
||||||
|
</br>
|
||||||
|
</li>
|
||||||
|
{% endfor %}
|
||||||
|
</ul>
|
||||||
|
<a href="{{ url_for('index') }}"> Back </a>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
0
tests/performance_tests/__init__.py
Normal file
0
tests/performance_tests/__init__.py
Normal file
28
tests/performance_tests/locustfile.py
Normal file
28
tests/performance_tests/locustfile.py
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
from locust import HttpUser, task
|
||||||
|
|
||||||
|
|
||||||
|
class PerfConnectionTest(HttpUser):
|
||||||
|
|
||||||
|
@task
|
||||||
|
def index(self):
|
||||||
|
response = self.client.get("/")
|
||||||
|
|
||||||
|
@task
|
||||||
|
def login(self):
|
||||||
|
response = self.client.post("/showSummary", {"email": "admin@irontemple.com"})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class PerfBookTest(HttpUser):
|
||||||
|
|
||||||
|
@task
|
||||||
|
def bookPlaces(self):
|
||||||
|
response = self.client.post("/showSummary", {"email": "admin@irontemple.com"})
|
||||||
|
response = self.client.post("/purchasePlaces", {"club": "Iron Temple", "competition": "Fall Classic", "places": 2})
|
||||||
|
|
||||||
|
|
||||||
|
class PerfBoard(HttpUser):
|
||||||
|
|
||||||
|
@task
|
||||||
|
def board(self):
|
||||||
|
response = self.client.get("/points")
|
||||||
24
tests/test_board.py
Normal file
24
tests/test_board.py
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
from bs4 import BeautifulSoup
|
||||||
|
from server import loadClubs
|
||||||
|
|
||||||
|
|
||||||
|
class TestBoardDisplayPoints:
|
||||||
|
|
||||||
|
def test_should_get_200(self, client):
|
||||||
|
'''
|
||||||
|
test if the page is retrieved
|
||||||
|
'''
|
||||||
|
response = client.get('/points')
|
||||||
|
assert response.status_code == 200
|
||||||
|
|
||||||
|
def test_should_display_right_size_list(self, client):
|
||||||
|
'''
|
||||||
|
test if the list of club displayed and in DB have the same size
|
||||||
|
'''
|
||||||
|
list_club = loadClubs()
|
||||||
|
response = client.get('/points')
|
||||||
|
soup = BeautifulSoup(response.data, "html.parser")
|
||||||
|
li = soup.find_all("li")
|
||||||
|
assert len(li) == len(list_club)
|
||||||
|
|
||||||
|
|
||||||
Reference in New Issue
Block a user