Skip to content

Commit

Permalink
Test find units endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
bkis committed Aug 30, 2023
1 parent 5f34e04 commit 5b4cf97
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
6 changes: 3 additions & 3 deletions Tekst-API/tekst/routers/units.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,9 +200,9 @@ async def find_units(
).to_list()

active_texts_restriction = (
In(LayerBaseDocument.text_id, [text.id for text in active_texts])
if not (user and user.is_superuser)
else {}
{}
if user and user.is_superuser
else In(LayerBaseDocument.text_id, [text.id for text in active_texts])
)

readable_layers = await LayerBaseDocument.find(
Expand Down
11 changes: 10 additions & 1 deletion Tekst-API/tests/integration/test_api_unit.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@


@pytest.mark.anyio
async def test_create_layer_unit(
async def test_create_unit(
api_path,
test_client: AsyncClient,
insert_test_data,
Expand Down Expand Up @@ -92,3 +92,12 @@ async def test_create_layer_unit(
endpoint = f"{api_path}/units/plaintext/637b9ad396d541a505e5439b"
resp = await test_client.patch(endpoint, json=unit_update, cookies=session_cookie)
assert resp.status_code == 400, status_fail_msg(400, resp)

# find all units
resp = await test_client.get(
f"{api_path}/units/", params={"limit": 100}, cookies=session_cookie
)
assert resp.status_code == 200, status_fail_msg(200, resp)
units = resp.json()
assert type(units) == list
assert len(units) > 0

0 comments on commit 5b4cf97

Please sign in to comment.