Skip to content
Open
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
1 change: 1 addition & 0 deletions infrahub_sdk/pytest_plugin/items/python_transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ def runtest(self) -> None:

class InfrahubPythonTransformIntegrationItem(InfrahubPythonTransformItem):
def runtest(self) -> None:
self.instantiate_transform()
input_data = self.session.infrahub_client.query_gql_query( # type: ignore[attr-defined]
self.transform_instance.query,
variables=self.test.spec.get_variables_data(), # type: ignore[union-attr]
Expand Down
2 changes: 1 addition & 1 deletion infrahub_sdk/pytest_plugin/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def collect_group(self, group: InfrahubTestGroup) -> Iterable[Item]:
def collect(self) -> Iterable[Item]:
raw = yaml.safe_load(self.path.open(encoding="utf-8"))

if "infrahub_tests" not in raw:
if not raw or "infrahub_tests" not in raw:
return

content = InfrahubTestFileV1(**raw)
Expand Down
6 changes: 4 additions & 2 deletions infrahub_sdk/pytest_plugin/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class InfrahubInputOutputTest(InfrahubBaseTest):
directory: Path | None = Field(
None, description="Path to the directory where the input and output files are located"
)
input: Path = Field(
input: Path | None = Field(
Path("input.json"),
description="Path to the file with the input data for the test, can be a relative path from the config file or from the directory.",
)
Expand Down Expand Up @@ -68,7 +68,7 @@ def update_paths(self, base_dir: Path) -> None:
else:
self.directory = base_dir

if not self.input or not self.input.is_file():
if self.input is not None and not self.input.is_file():
Copy link
Contributor

Choose a reason for hiding this comment

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

this is a slight functional change, just want to make sure that is intentional
previously if self.input was falsy, then this conditional would run, now it will not

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, this is due to integration tests not requiring an input.json due to live querying of the data for these.

We originally had to define a dummy input.json for integration tests, and this should not require it any longer for integration tests.

search_input: Path | str = self.input or "input.*"
results = list(self.directory.rglob(str(search_input)))

Expand Down Expand Up @@ -99,6 +99,8 @@ def get_output_data(self) -> Any:


class InfrahubIntegrationTest(InfrahubInputOutputTest):
# Integration tests get input from live GraphQL queries, not from input files
input: Path | None = Field(None)
variables: Path | dict[str, Any] = Field(
Path("variables.json"), description="Variables and corresponding values to pass to the GraphQL query"
)
Expand Down