Skip to content

Commit

Permalink
Change graphql subscription detail tests to not run separate
Browse files Browse the repository at this point in the history
- change unit test github action to not run graphql separately
- update override_class function typing.

Fixes: #393, #310
  • Loading branch information
tjeerddie committed Jan 16, 2024
1 parent 064a8ca commit 4cb256b
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 45 deletions.
34 changes: 1 addition & 33 deletions .github/workflows/run-unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,39 +50,7 @@ jobs:
env:
FLIT_ROOT_INSTALL: 1
- name: Run Unit tests
run: CACHE_URI=redis://redis DATABASE_URI=postgresql://$POSTGRES_USER:$POSTGRES_PASSWORD@$POSTGRES_HOST/$POSTGRES_DB pytest --cov-branch --cov=orchestrator --cov-report=xml --ignore=test --ignore=orchestrator/devtools --ignore=examples --ignore=docs --ignore=test/unit_tests/graphql
env:
POSTGRES_DB: orchestrator-core-test
POSTGRES_USER: nwa
POSTGRES_PASSWORD: nwa
POSTGRES_HOST: postgres
ENVIRONMENT: TESTING
- name: Run Graphql Unit tests
run: AIOCACHE_DISABLE=1 CACHE_URI=redis://redis DATABASE_URI=postgresql://$POSTGRES_USER:$POSTGRES_PASSWORD@$POSTGRES_HOST/$POSTGRES_DB pytest ./test/unit_tests/graphql
env:
POSTGRES_DB: orchestrator-core-test
POSTGRES_USER: nwa
POSTGRES_PASSWORD: nwa
POSTGRES_HOST: postgres
ENVIRONMENT: TESTING
- name: Run test_subscriptions_product_generic_one Unit test
run: CACHE_URI=redis://redis DATABASE_URI=postgresql://$POSTGRES_USER:$POSTGRES_PASSWORD@$POSTGRES_HOST/$POSTGRES_DB pytest ./test/unit_tests/ -k test_subscriptions_product_generic_one
env:
POSTGRES_DB: orchestrator-core-test
POSTGRES_USER: nwa
POSTGRES_PASSWORD: nwa
POSTGRES_HOST: postgres
ENVIRONMENT: TESTING
- name: Run test_single_subscription_product_list_union_type_provisioning_subscription Unit test
run: CACHE_URI=redis://redis DATABASE_URI=postgresql://$POSTGRES_USER:$POSTGRES_PASSWORD@$POSTGRES_HOST/$POSTGRES_DB pytest ./test/unit_tests/ -k test_single_subscription_product_list_union_type_provisioning_subscription
env:
POSTGRES_DB: orchestrator-core-test
POSTGRES_USER: nwa
POSTGRES_PASSWORD: nwa
POSTGRES_HOST: postgres
ENVIRONMENT: TESTING
- name: Run test_single_subscription_product_list_union_type_terminated_subscription Unit test
run: CACHE_URI=redis://redis DATABASE_URI=postgresql://$POSTGRES_USER:$POSTGRES_PASSWORD@$POSTGRES_HOST/$POSTGRES_DB pytest ./test/unit_tests/ -k test_single_subscription_product_list_union_type_terminated_subscription
run: CACHE_URI=redis://redis DATABASE_URI=postgresql://$POSTGRES_USER:$POSTGRES_PASSWORD@$POSTGRES_HOST/$POSTGRES_DB pytest --cov-branch --cov=orchestrator --cov-report=xml --ignore=test --ignore=orchestrator/devtools --ignore=examples --ignore=docs
env:
POSTGRES_DB: orchestrator-core-test
POSTGRES_USER: nwa
Expand Down
6 changes: 3 additions & 3 deletions orchestrator/graphql/utils/override_class.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from typing import Any
from typing import Type

from strawberry.field import StrawberryField


def override_class(strawberry_class: Any, fields: list[StrawberryField]) -> Any:
def override_class(strawberry_class: Type, fields: list[StrawberryField]) -> Type:
"""Override fields or add fields to a existing strawberry class.
Usefull for overriding orchestrator core strawberry classes.
Expand All @@ -20,7 +20,7 @@ def override_class(strawberry_class: Any, fields: list[StrawberryField]) -> Any:

fields_map = {field.name: field for field in fields}

def override_fn(field: Any) -> Any:
def override_fn(field: StrawberryField) -> StrawberryField:
if custom_field := fields_map.get(field.name):
field.base_resolver = custom_field.base_resolver
return field
Expand Down
9 changes: 0 additions & 9 deletions test/unit_tests/graphql/test_subscriptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -1277,11 +1277,6 @@ def test_single_subscription_metadata_and_schema(
}


def expect_fail_test_if_too_many_duplicate_types_in_interface(result):
if "errors" in result and "are you using a strawberry.field" in result["errors"][0]["message"]:
pytest.xfail("Test fails when executed with all tests")


def test_subscriptions_product_generic_one(
fastapi_app_graphql,
test_client,
Expand All @@ -1298,7 +1293,6 @@ def test_subscriptions_product_generic_one(

assert HTTPStatus.OK == response.status_code
result = response.json()
expect_fail_test_if_too_many_duplicate_types_in_interface(result)

subscriptions_data = result["data"]["subscriptions"]
subscriptions = subscriptions_data["page"]
Expand Down Expand Up @@ -1332,7 +1326,6 @@ def test_single_subscription_product_list_union_type(

assert HTTPStatus.OK == response.status_code
result = response.json()
expect_fail_test_if_too_many_duplicate_types_in_interface(result)

subscriptions_data = result["data"]["subscriptions"]
subscriptions = subscriptions_data["page"]
Expand Down Expand Up @@ -1374,7 +1367,6 @@ def test_single_subscription_product_list_union_type_provisioning_subscription(

assert HTTPStatus.OK == response.status_code
result = response.json()
expect_fail_test_if_too_many_duplicate_types_in_interface(result)

subscriptions_data = result["data"]["subscriptions"]
subscriptions = subscriptions_data["page"]
Expand Down Expand Up @@ -1416,7 +1408,6 @@ def test_single_subscription_product_list_union_type_terminated_subscription(

assert HTTPStatus.OK == response.status_code
result = response.json()
expect_fail_test_if_too_many_duplicate_types_in_interface(result)

subscriptions_data = result["data"]["subscriptions"]
subscriptions = subscriptions_data["page"]
Expand Down

0 comments on commit 4cb256b

Please sign in to comment.