diff --git a/test_app/schema/schema.yaml b/test_app/schema/schema.yaml index 17b3b93..a368a4c 100644 --- a/test_app/schema/schema.yaml +++ b/test_app/schema/schema.yaml @@ -355,6 +355,7 @@ classes: - EntityMixin attributes: name: + description: This is a field description range: string required: true auto_inc_field: diff --git a/test_app/tests/test_auto_values.py b/test_app/tests/test_auto_values.py index eef63f8..81d2862 100644 --- a/test_app/tests/test_auto_values.py +++ b/test_app/tests/test_auto_values.py @@ -10,60 +10,6 @@ date_now = datetime.datetime.now() - -@pytest.mark.asyncio -async def test_graphql_query( - sync_db: SyncDB, - gql_client: GQLTestClient, -) -> None: - """ - Test that we can only fetch samples from the database that we have access to - """ - user_id = 12345 - secondary_user_id = 67890 - project_id = 123 - - # Create mock data - with sync_db.session() as session: - SessionStorage.set_session(session) - SampleFactory.create_batch( - 2, - collection_location="San Francisco, CA", - collection_date=date_now, - owner_user_id=user_id, - collection_id=project_id, - ) - SampleFactory.create_batch( - 6, - collection_location="Mountain View, CA", - collection_date=date_now, - owner_user_id=user_id, - collection_id=project_id, - ) - SampleFactory.create_batch( - 4, - collection_location="Phoenix, AZ", - collection_date=date_now, - owner_user_id=secondary_user_id, - collection_id=9999, - ) - - # Fetch all samples - query = """ - query MyQuery { - samples { - id, - collectionLocation - } - } - """ - output = await gql_client.query(query, user_id=user_id, member_projects=[project_id]) - locations = [sample["collectionLocation"] for sample in output["data"]["samples"]] - assert "San Francisco, CA" in locations - assert "Mountain View, CA" in locations - assert "Phoenix, AZ" not in locations - - @pytest.mark.asyncio async def test_autoupdate_fields(gql_client: GQLTestClient, sync_db: SyncDB) -> None: """ diff --git a/test_app/tests/test_field_descriptions.py b/test_app/tests/test_field_descriptions.py new file mode 100644 index 0000000..0eed013 --- /dev/null +++ b/test_app/tests/test_field_descriptions.py @@ -0,0 +1,38 @@ +""" +Test that field descriptions are present in the GQL API +""" + +import datetime +import pytest +from conftest import GQLTestClient + +date_now = datetime.datetime.now() + + +@pytest.mark.asyncio +async def test_field_description( + gql_client: GQLTestClient, +) -> None: + """ + Test that we can only fetch samples from the database that we have access to + """ + + # Fetch all samples + query = """ + { + __type(name: "AutoUpdatedType") { + name + fields { + name + description + } + } + } + """ + output = await gql_client.query(query, user_id=999, member_projects=[999]) + fields = output["data"]["__type"]["fields"] + field = {} + for field in fields: + if field["name"] == "name": + break + assert field["description"] == "This is a field description"