Skip to content
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

[CZID-8697] Codegen tests - part 1 #119

Merged
merged 15 commits into from
Nov 16, 2023

Conversation

robertaboukhalil
Copy link
Contributor

@robertaboukhalil robertaboukhalil commented Nov 15, 2023

Part 1 of adding codegen tests

  • Allowing us to run tests on either real schema or mock schema
  • In the next PR, I'll add a lot more tests on the codegen -- there are a lot of changes to do, so I want to split it up

@robertaboukhalil robertaboukhalil changed the title Raboukhalil/czid 8697 codegen tests [CZID-8697] Codegen tests - part 1 Nov 16, 2023
# Make sure tests can get their own instances of the app.
def get_app() -> FastAPI:
def get_app(use_test_schema: bool = False) -> FastAPI:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Allow us to define whether to use the test schema or not


import pytest
from api.conftest import GQLTestClient

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An example of where tests on our real schema would go

@@ -123,6 +125,9 @@ def api_generate(ctx: click.Context, schemafile: str, output_prefix: str) -> Non
view.imports_closure()
wrapped_view = ViewWrapper(view)

for dir in DIR_CODEGEN:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The first time you run codegen, folders don't exist

@@ -13,7 +13,7 @@ from api.types.{{ class.snake_name }} import {{ class.name }}, resolve_{{ class.
@strawberry.type
class Query:
# Allow queries by node ID
node: relay.Node = relay.node()
nodes: List[relay.Node] = relay.node()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updating the relay query as per Strawberry docs to support an array of node IDs (will check with FE team what they're expected use case for this is)

from fastapi import FastAPI
from api.conftest import GQLTestClient


Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just want to be sure we're testing the right schema 🙂

@robertaboukhalil robertaboukhalil marked this pull request as ready for review November 16, 2023 18:17
…mics into raboukhalil/CZID-8697-codegen-tests

# Conflicts:
#	.gitattributes
@robertaboukhalil robertaboukhalil merged commit 42729f8 into main Nov 16, 2023
@robertaboukhalil robertaboukhalil deleted the raboukhalil/CZID-8697-codegen-tests branch November 16, 2023 22:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants