-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support LinkML field names with spaces. (#75)
* Temp commit, improve error msgs. * Don't depend on a base Entity class in the platformics lib. * Convert spaces in field names to underscores in python, and camelCase in GQL * Make sure there's an actual value there.
- Loading branch information
Showing
5 changed files
with
56 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
""" | ||
Test basic queries and mutations | ||
""" | ||
|
||
import datetime | ||
import pytest | ||
from platformics.database.connect import SyncDB | ||
from conftest import GQLTestClient, SessionStorage | ||
from test_infra.factories.constraint_checked_type import ConstraintCheckedTypeFactory | ||
|
||
date_now = datetime.datetime.now() | ||
|
||
|
||
@pytest.mark.asyncio | ||
async def test_field_with_spaces( | ||
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 | ||
project_id = 123 | ||
|
||
# Create mock data | ||
with sync_db.session() as session: | ||
SessionStorage.set_session(session) | ||
cct = ConstraintCheckedTypeFactory.create( | ||
owner_user_id=user_id, | ||
collection_id=project_id, | ||
) | ||
|
||
# Fetch the row via gql | ||
query = """ | ||
query MyQuery { | ||
constraintCheckedTypes { | ||
id, | ||
fieldWithSpaces | ||
} | ||
} | ||
""" | ||
output = await gql_client.query(query, user_id=user_id, member_projects=[project_id]) | ||
assert cct.field_with_spaces == output["data"]["constraintCheckedTypes"][0]["fieldWithSpaces"] | ||
assert output["data"]["constraintCheckedTypes"][0]["fieldWithSpaces"] |