Skip to content

Commit

Permalink
more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
csae8092 committed Mar 20, 2024
1 parent 9584acd commit 18126b7
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 2 deletions.
19 changes: 19 additions & 0 deletions app/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,25 @@
BASEROW_PW = os.environ.get("BASEROW_PW")

DATABASES = {
"test":
{
"db_name": "Test DB",
"db_id": "538",
"endpoints": {
"persons": {
"table_id": "3284",
"search_field_name": "name",
"search_field_id": "29742",
"id_field_name": "project_id"
},
"places": {
"table_id": "3285",
"search_field_name": "name",
"search_field_id": "29745",
"id_field_name": "project_id"
}
}
},
"emt":
{
"db_name": "EMT",
Expand Down
29 changes: 28 additions & 1 deletion app/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,32 @@ def test_read_main():
def test_correct_endpoint_number():
with TestClient(app) as client:
response = client.get("/")
endpoints = response.json()['endpoints']
endpoints = response.json()["endpoints"]
assert len(endpoints) == len(DATABASES)


def test_ac_endpoint():
db_id = "test"
endpoints = [key for key, _ in DATABASES[db_id]["endpoints"].items()]
for x in endpoints:
with TestClient(app) as client:
response = client.get(f"/ac/{db_id}/{x}")
assert response.status_code == 422
response = client.get(f"/ac/{db_id}/{x}?q=A")
assert response.status_code == 200


def test_nonexiting_ac_endpoint():
with TestClient(app) as client:
response = client.get("/ac/quatsch/blödsinn?q=A")
assert response.status_code == 404


def test_list_tables_endpoint():
db_id = "test"
with TestClient(app) as client:
response = client.get(f"/db/{db_id}/tables")
assert response.status_code == 200
with TestClient(app) as client:
response = client.get("/db/blödsinn/tables")
assert response.status_code == 404
3 changes: 2 additions & 1 deletion run_tests.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#/bin/bash

coverage run -m pytest -v
echo "Be aware that we are ignoring warnings, this might come back to you one day!"
coverage run -m pytest -v -p no:warnings
coverage report
coverage html
xdg-open ./htmlcov/index.html

0 comments on commit 18126b7

Please sign in to comment.