diff --git a/Tekst-API/tekst/routers/units.py b/Tekst-API/tekst/routers/units.py index efa2472e..2b40b234 100644 --- a/Tekst-API/tekst/routers/units.py +++ b/Tekst-API/tekst/routers/units.py @@ -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( diff --git a/Tekst-API/tests/integration/test_api_unit.py b/Tekst-API/tests/integration/test_api_unit.py index 780de4d5..bb4b69ed 100644 --- a/Tekst-API/tests/integration/test_api_unit.py +++ b/Tekst-API/tests/integration/test_api_unit.py @@ -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, @@ -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