diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 537c7969e..1c393efd1 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -13,7 +13,7 @@ repos: - repo: https://github.com/astral-sh/ruff-pre-commit # Ruff version. - rev: v0.11.9 + rev: v0.14.10 hooks: # Run the linter. - id: ruff diff --git a/infrahub_sdk/testing/schemas/car_person.py b/infrahub_sdk/testing/schemas/car_person.py index 3a1c3dc3c..a9f4ed494 100644 --- a/infrahub_sdk/testing/schemas/car_person.py +++ b/infrahub_sdk/testing/schemas/car_person.py @@ -18,7 +18,7 @@ TESTING_MANUFACTURER = f"{NAMESPACE}Manufacturer" TESTING_PERSON = f"{NAMESPACE}Person" TESTING_CAR = f"{NAMESPACE}Car" -BUILTIN_TAG = "BuiltinTag" +TESTING_TAG = f"{NAMESPACE}Tag" @dataclass @@ -40,7 +40,7 @@ class TestingCarData: kind: str = TESTING_CAR -class SchemaCarPerson: +class SchemaCarPersonFixtures: @pytest.fixture(scope="class") def schema_person_base(self) -> NodeSchema: return NodeSchema( @@ -94,7 +94,7 @@ def schema_car_base(self) -> NodeSchema: Rel( name="tags", optional=True, - peer=BUILTIN_TAG, + peer=TESTING_TAG, cardinality="many", ), ], @@ -132,14 +132,32 @@ def schema_manufacturer_base(self) -> NodeSchema: ], ) + @pytest.fixture(scope="class") + def testing_tag_base(self) -> NodeSchema: + return NodeSchema( + name="Tag", + namespace="Testing", + include_in_menu=True, + label="Tag", + default_filter="name__value", + display_labels=["name__value"], + attributes=[ + Attr(name="name", kind=AttributeKind.TEXT, unique=True), + Attr(name="description", kind=AttributeKind.TEXT, optional=True), + ], + ) + @pytest.fixture(scope="class") def schema_base( self, schema_car_base: NodeSchema, schema_person_base: NodeSchema, schema_manufacturer_base: NodeSchema, + testing_tag_base: NodeSchema, ) -> SchemaRoot: - return SchemaRoot(version="1.0", nodes=[schema_car_base, schema_person_base, schema_manufacturer_base]) + return SchemaRoot( + version="1.0", nodes=[schema_car_base, schema_person_base, schema_manufacturer_base, testing_tag_base] + ) @pytest.fixture(scope="class") async def person_joe_data(self) -> TestingPersonData: @@ -199,22 +217,24 @@ async def car_golf( @pytest.fixture(scope="class") async def tag_blue(self, client: InfrahubClient) -> InfrahubNode: - obj = await client.create(kind=BUILTIN_TAG, name="Blue") + obj = await client.create(kind=TESTING_TAG, name="Blue") await obj.save() return obj @pytest.fixture(scope="class") async def tag_red(self, client: InfrahubClient) -> InfrahubNode: - obj = await client.create(kind=BUILTIN_TAG, name="Red") + obj = await client.create(kind=TESTING_TAG, name="Red") await obj.save() return obj @pytest.fixture(scope="class") async def tag_green(self, client: InfrahubClient) -> InfrahubNode: - obj = await client.create(kind=BUILTIN_TAG, name="Green") + obj = await client.create(kind=TESTING_TAG, name="Green") await obj.save() return obj + +class SchemaCarPerson(SchemaCarPersonFixtures): async def create_persons(self, client: InfrahubClient, branch: str) -> list[InfrahubNode]: john = await client.create(kind=TESTING_PERSON, name="John Doe", branch=branch) await john.save()