Skip to content

Conversation

@dgarros
Copy link
Contributor

@dgarros dgarros commented Mar 9, 2025

Fix #18

This PR adds some integration tests for Task and fixes various issues related to task
In order to fully support task, this PR also adds the support for Enum to GraphQL query and mutation (#18)

By default, an enum will be rendered as an Enum but it's also possible to convert Enum to their respective value.

@codecov
Copy link

codecov bot commented Mar 9, 2025

Codecov Report

Attention: Patch coverage is 92.00000% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
infrahub_sdk/graphql.py 94.11% 1 Missing ⚠️
infrahub_sdk/task/manager.py 80.00% 1 Missing ⚠️
@@                 Coverage Diff                  @@
##           infrahub-develop     #299      +/-   ##
====================================================
+ Coverage             70.62%   71.04%   +0.41%     
====================================================
  Files                    85       86       +1     
  Lines                  7824     7849      +25     
  Branches               1513     1520       +7     
====================================================
+ Hits                   5526     5576      +50     
+ Misses                 1908     1881      -27     
- Partials                390      392       +2     
Flag Coverage Δ
integration-tests 22.72% <36.00%> (+1.05%) ⬆️
python-3.10 45.29% <40.00%> (+<0.01%) ⬆️
python-3.11 45.29% <40.00%> (-0.02%) ⬇️
python-3.12 45.29% <40.00%> (+<0.01%) ⬆️
python-3.13 45.31% <40.00%> (+<0.01%) ⬆️
python-3.9 44.20% <40.00%> (+0.02%) ⬆️
python-filler-3.12 24.58% <48.00%> (+0.04%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
infrahub_sdk/task/__init__.py 100.00% <100.00%> (ø)
infrahub_sdk/graphql.py 96.36% <94.11%> (+0.17%) ⬆️
infrahub_sdk/task/manager.py 75.44% <80.00%> (+15.44%) ⬆️

... and 2 files with indirect coverage changes

🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@dgarros dgarros marked this pull request as ready for review March 9, 2025 16:30
@dgarros dgarros requested a review from a team March 9, 2025 16:30
Copy link
Contributor

@ogenstad ogenstad left a comment

Choose a reason for hiding this comment

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

I think we'll need to take a closer look at enums in general as there are different variations. We have our own Enums (which doesn't yet behave as GraphQL enums) within the schema that are different than GraphQL enums. I'm not sure this comes across anywhere. Than I think there might be more to be done with regards to the generation of Python protocols when it comes to enums.



def convert_to_graphql_as_string(value: str | bool | list) -> str:
def convert_to_graphql_as_string(value: str | bool | list | BaseModel | Enum | Any, convert_enum: bool = False) -> str: # noqa: PLR0911
Copy link
Contributor

Choose a reason for hiding this comment

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

In some other places for PLR0911 we've assigned the return value within multiple if-statements / match cases like this to avoid having a high number of returns.

@dgarros dgarros merged commit 42ee591 into infrahub-develop Mar 11, 2025
17 checks passed
@dgarros dgarros deleted the dga-20250309-cont-task-enum-support branch March 11, 2025 07:25
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.

2 participants