Skip to content

Commit b8186de

Browse files
authored
Merge pull request #432 from opsmill/stable
Merge stable into develop
2 parents 79f3e93 + 8a6f8e7 commit b8186de

File tree

6 files changed

+79
-5
lines changed

6 files changed

+79
-5
lines changed

CHANGELOG.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,22 @@ This project uses [*towncrier*](https://towncrier.readthedocs.io/) and the chang
1111

1212
<!-- towncrier release notes start -->
1313

14+
## [1.12.2](https://github.com/opsmill/infrahub-sdk-python/tree/v1.12.2) - 2025-06-05
15+
16+
### Fixed
17+
18+
- fix bug in Timestamp.add by @ajtmccarty in [#403](https://github.com/opsmill/infrahub-sdk-python/pull/403)
19+
- utils.py: improve file not found exception message by @granoe668 in [#425](https://github.com/opsmill/infrahub-sdk-python/pull/425)
20+
21+
### Changed
22+
23+
- Add partial_match to the client.count() by @BeArchiTek in [#411](https://github.com/opsmill/infrahub-sdk-python/pull/411)
24+
25+
### Housekeeping
26+
27+
- Loosen pinned requirement for `whenever` to allow versions from 0.7.2 up to but not including 0.8.0.
28+
- Bump http-proxy-middleware from 2.0.7 to 2.0.9 in /docs by @dependabot in [#418](https://github.com/opsmill/infrahub-sdk-python/pull/418)
29+
1430
## [1.12.1](https://github.com/opsmill/infrahub-sdk-python/tree/v1.12.1) - 2025-05-12
1531

1632
### Changed

changelog/+26b92d23.housekeeping.md

Lines changed: 0 additions & 1 deletion
This file was deleted.

infrahub_sdk/pytest_plugin/items/python_transform.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import ujson
88
from httpx import HTTPStatusError
99

10+
from ...node import InfrahubNode
1011
from ..exceptions import OutputMatchError, PythonTransformDefinitionError
1112
from ..models import InfrahubTestExpectedResult
1213
from .base import InfrahubItem
@@ -41,7 +42,7 @@ def instantiate_transform(self) -> None:
4142
)
4243
client = self.session.infrahub_client # type: ignore[attr-defined]
4344
# TODO: Look into seeing how a transform class may use the branch, but set as a empty string for the time being to keep current behaviour
44-
self.transform_instance = transform_class(branch="", client=client)
45+
self.transform_instance = transform_class(branch="", client=client, infrahub_node=InfrahubNode)
4546

4647
def run_transform(self, variables: dict[str, Any]) -> Any:
4748
self.instantiate_transform()

poetry.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "infrahub-sdk"
3-
version = "1.12.1"
3+
version = "1.12.2"
44
description = "Python Client to interact with Infrahub"
55
authors = ["OpsMill <info@opsmill.com>"]
66
readme = "README.md"
@@ -35,7 +35,7 @@ numpy = [
3535
{ version = "^1.26.2", optional = true, python = ">=3.12" },
3636
]
3737
pyarrow = { version = ">=14", optional = true }
38-
rich = { version = "^13", optional = true }
38+
rich = { version = ">=12, <14", optional = true }
3939
toml = { version = "^0.10", optional = true }
4040
typer = { version = "^0.12.3", optional = true }
4141
pytest = { version = "*", optional = true }

tests/unit/pytest_plugin/test_plugin.py

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,3 +231,61 @@ def test_jinja2_transform_unexpected_output(pytester):
231231

232232
result = pytester.runpytest("--infrahub-repo-config=infrahub_config.yml")
233233
result.assert_outcomes(failed=1)
234+
235+
236+
def test_python_transform(pytester):
237+
pytester.makefile(
238+
".yml",
239+
test_python_transform="""
240+
---
241+
version: "1.0"
242+
infrahub_tests:
243+
- resource: "PythonTransform"
244+
resource_name: "device_config"
245+
tests:
246+
- name: "base_config"
247+
expect: PASS
248+
spec:
249+
kind: "python-transform-unit-process"
250+
directory: device_config/base_config
251+
""",
252+
)
253+
pytester.makefile(
254+
".yml",
255+
infrahub_config="""
256+
---
257+
schemas:
258+
- schemas/dcim.yml
259+
260+
python_transforms:
261+
- name: device_config
262+
class_name: "DeviceConfig"
263+
file_path: "transforms/device_config.py"
264+
""",
265+
)
266+
test_input = pytester.makefile(
267+
".json", input='{"data": { "InfraDevice": { "edges": [ { "node": { "name": {"value": "atl1-edge1"} } } ] } } }'
268+
)
269+
test_output = pytester.makefile(".json", output='{"hostname": "atl1-edge1"}')
270+
test_template = pytester.makefile(
271+
".py",
272+
device_config="""
273+
from infrahub_sdk.transforms import InfrahubTransform
274+
275+
class DeviceConfig(InfrahubTransform):
276+
query = "device_config"
277+
async def transform(self, data):
278+
return {"hostname": data["InfraDevice"]["edges"][0]["node"]["name"]["value"]}
279+
""",
280+
)
281+
282+
pytester.mkdir("device_config")
283+
test_dir = pytester.mkdir("device_config/base_config")
284+
pytester.run("mv", test_input, test_dir)
285+
pytester.run("mv", test_output, test_dir)
286+
287+
transform_dir = pytester.mkdir("transforms")
288+
pytester.run("mv", test_template, transform_dir)
289+
290+
result = pytester.runpytest("--infrahub-repo-config=infrahub_config.yml")
291+
result.assert_outcomes(passed=1)

0 commit comments

Comments
 (0)