Skip to content

Commit 01e2c7b

Browse files
committed
(test) unit test
1 parent c1fc303 commit 01e2c7b

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

tests/unit_test.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import json
2+
from server import loadCompetitions, app
3+
4+
5+
def test_loadCompetitions(tmpdir):
6+
competitions = [
7+
{"name": "Competition1", "numberOfPlaces": "15"},
8+
{"name": "Competition2", "numberOfPlaces": "10"},
9+
]
10+
competitions_file = tmpdir.join("test_competitions.json")
11+
12+
with open(competitions_file, "w") as f:
13+
json.dump({"competitions": competitions}, f)
14+
15+
app.config["COMPETITIONS_FILE"] = str(competitions_file)
16+
17+
loaded_competitions = loadCompetitions()
18+
assert loaded_competitions == competitions

0 commit comments

Comments
 (0)