Skip to content

added fix/test for missing model title; #23

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion nshm_model_graphql_api/schema/nshm_model_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ def get_node(cls, info, version: str):

def get_nshm_models() -> Iterator[NshmModel]:
for version in nm.all_model_versions():
yield NshmModel(version=version)
model = nm.get_model_version(version)
yield NshmModel(version=model.version, title=model.title)


def get_nshm_model(version: Optional[str] = None) -> Optional[NshmModel]:
Expand Down
7 changes: 7 additions & 0 deletions tests/test_schema_models.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import pytest
from graphene.test import Client
from graphql_relay import to_global_id

from nshm_model_graphql_api import schema

Expand All @@ -13,13 +14,19 @@ def test_get_models(client):
QUERY = """
query {
get_models {
id
version
title
}
}
"""
executed = client.execute(QUERY)
print(executed)
assert executed["data"]["get_models"][0]["version"] == "NSHM_v1.0.0"
assert executed["data"]["get_models"][0]["title"] == "Initial version"
assert executed["data"]["get_models"][0]["id"] == to_global_id(
"NshmModel", "NSHM_v1.0.0"
)


def test_get_model_default(client):
Expand Down
Loading