Skip to content

Commit

Permalink
UPDATE route_pf.py - fix bug where list_footprints not returning prop…
Browse files Browse the repository at this point in the history
…erly
  • Loading branch information
JohnVonNeumann committed Mar 18, 2024
1 parent fd0c6cf commit bcbdaf9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
2 changes: 1 addition & 1 deletion apis/version1/route_product_footprints.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ def list_footprints(db: Session = Depends(get_db), current_user: User = Depends(
"""
product_footprints = list_product_footprints(db=db)
if not product_footprints or len(product_footprints) == 0:
raise NoSuchFootprintException
return {'data': []}

return paginate(product_footprints, transformer=transformer)

Expand Down
17 changes: 8 additions & 9 deletions tests/test_routes/test_product_footprints_route.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,30 +92,29 @@ def test_read_product_footprint_not_found(client, auth_header):
assert response.json()["detail"] == "The specified footprint does not exist" # Match your exception message


def test_read_product_footprints_no_seeding(client, auth_header):
response = client.get("/footprints/?limit=1", headers=auth_header)
def test_list_product_footprints_not_found(client, auth_header):
response = client.get("/footprints/", headers=auth_header)
assert response.status_code == 200
print(f"data = {response.json()['data']}")
assert len(response.json()["data"]) == 1
assert len(response.json()["data"]) == 0


def test_read_product_footprints(client, auth_header, seed_database):
response = client.get("/footprints/?offset=1", headers=auth_header)
response = client.get("/footprints/", headers=auth_header)
assert response.status_code == 200
print(f"data = {response.json()['data']}")
assert len(response.json()["data"]) == 5
assert response.json()
assert response.json()["data"][1]
assert response.json()["data"][4]


def test_read_product_footprints_with_offset(client, auth_header, seed_database):
response = client.get("/footprints/", headers=auth_header)
response = client.get("/footprints/?offset=3", headers=auth_header)
assert response.status_code == 200
print(f"data = {response.json()['data']}")
assert len(response.json()["data"]) == 11
assert len(response.json()["data"]) == 2
assert response.json()
assert response.json()["data"][0]
assert response.json()["data"][1]
assert response.json()["data"][2]


def test_read_product_footprints_with_limit(client, auth_header, seed_database):
Expand Down

0 comments on commit bcbdaf9

Please sign in to comment.