Spaces:
Running
Running
sghorbal
commited on
Commit
·
3248a8c
1
Parent(s):
eb36732
test the reference data API retrieval
Browse files- tests/test_api.py +44 -0
tests/test_api.py
CHANGED
|
@@ -43,3 +43,47 @@ def test_insert_match_integrity_error(client, db_session, wimbledon_final_raw):
|
|
| 43 |
response = client.post("/match/insert", json=wimbledon_final_raw)
|
| 44 |
|
| 45 |
assert response.status_code == HTTP_422_UNPROCESSABLE_ENTITY, f"Status code should be {HTTP_422_UNPROCESSABLE_ENTITY} for duplicate match"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 43 |
response = client.post("/match/insert", json=wimbledon_final_raw)
|
| 44 |
|
| 45 |
assert response.status_code == HTTP_422_UNPROCESSABLE_ENTITY, f"Status code should be {HTTP_422_UNPROCESSABLE_ENTITY} for duplicate match"
|
| 46 |
+
|
| 47 |
+
def test_list_surfaces(client, with_materialized_views):
|
| 48 |
+
"""
|
| 49 |
+
Test the list of surfaces
|
| 50 |
+
"""
|
| 51 |
+
response = client.get("/references/surfaces")
|
| 52 |
+
|
| 53 |
+
assert response.status_code == HTTP_200_OK
|
| 54 |
+
assert set(response.json()) == set([
|
| 55 |
+
"Carpet",
|
| 56 |
+
"Clay",
|
| 57 |
+
"Grass",
|
| 58 |
+
"Hard",
|
| 59 |
+
])
|
| 60 |
+
|
| 61 |
+
def test_list_courts(client, with_materialized_views):
|
| 62 |
+
"""
|
| 63 |
+
Test the list of courts
|
| 64 |
+
"""
|
| 65 |
+
response = client.get("/references/courts")
|
| 66 |
+
|
| 67 |
+
assert response.status_code == HTTP_200_OK
|
| 68 |
+
assert set(response.json()) == set([
|
| 69 |
+
"Indoor",
|
| 70 |
+
"Outdoor",
|
| 71 |
+
])
|
| 72 |
+
|
| 73 |
+
def test_list_series(client, with_materialized_views):
|
| 74 |
+
"""
|
| 75 |
+
Test the list of surfaces
|
| 76 |
+
"""
|
| 77 |
+
response = client.get("/references/series")
|
| 78 |
+
|
| 79 |
+
assert response.status_code == HTTP_200_OK
|
| 80 |
+
assert set(response.json()) == set([
|
| 81 |
+
"ATP250",
|
| 82 |
+
"ATP500",
|
| 83 |
+
"Grand Slam",
|
| 84 |
+
"International",
|
| 85 |
+
"International Gold",
|
| 86 |
+
"Masters",
|
| 87 |
+
"Masters 1000",
|
| 88 |
+
"Masters Cup"
|
| 89 |
+
])
|