Skip to content
Closed
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
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
34 changes: 27 additions & 7 deletions infrahub_sdk/testing/schemas/car_person.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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(
Expand Down Expand Up @@ -94,7 +94,7 @@ def schema_car_base(self) -> NodeSchema:
Rel(
name="tags",
optional=True,
peer=BUILTIN_TAG,
peer=TESTING_TAG,
cardinality="many",
),
],
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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()
Expand Down