Skip to content

Commit

Permalink
Disable order tests
Browse files Browse the repository at this point in the history
  • Loading branch information
LucasG0 committed Jan 9, 2025
1 parent e5e2aca commit d92173d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
1 change: 1 addition & 0 deletions changelog/+nodes-order.added.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
`client.all` and `client.filters` now support `order` parameter allowing to disable order of retrieve nodes in order to enhance performances
26 changes: 14 additions & 12 deletions tests/integration/test_infrahub_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
from infrahub_sdk.schema import ProfileSchemaAPI
from infrahub_sdk.testing.docker import TestInfrahubDockerClient
from infrahub_sdk.testing.schemas.animal import TESTING_ANIMAL, TESTING_CAT, TESTING_DOG, TESTING_PERSON, SchemaAnimal
from infrahub_sdk.types import Order

if TYPE_CHECKING:
from infrahub_sdk import InfrahubClient
Expand Down Expand Up @@ -62,17 +61,20 @@ async def test_get_all(self, client: InfrahubClient, base_dataset):
assert isinstance(nodes[0], InfrahubNode)
assert [node.name.value for node in nodes] == ["Bella", "Luna"]

async def test_get_all_no_order(self, client: InfrahubClient, base_dataset):
nodes = await client.all(kind=TESTING_CAT, order=Order(disable=True))
assert len(nodes) == 2
assert isinstance(nodes[0], InfrahubNode)
assert {node.name.value for node in nodes} == {"Bella", "Luna"}

async def test_get_filters_no_order(self, client: InfrahubClient, base_dataset):
nodes = await client.filters(kind=TESTING_CAT, order=Order(disable=True))
assert len(nodes) == 2
assert isinstance(nodes[0], InfrahubNode)
assert {node.name.value for node in nodes} == {"Bella", "Luna"}
# TODO enable these tests for infrahub version containing this commit
# https://github.com/opsmill/infrahub/commit/5a4d6860196b5bfb51fb8a124f33125f4a0b6753
# when we support testing against multiple infrahub versions.
# async def test_get_all_no_order(self, client: InfrahubClient, base_dataset):
# nodes = await client.all(kind=TESTING_CAT, order=Order(disable=True))
# assert len(nodes) == 2
# assert isinstance(nodes[0], InfrahubNode)
# assert {node.name.value for node in nodes} == {"Bella", "Luna"}
#
# async def test_get_filters_no_order(self, client: InfrahubClient, base_dataset):
# nodes = await client.filters(kind=TESTING_CAT, order=Order(disable=True))
# assert len(nodes) == 2
# assert isinstance(nodes[0], InfrahubNode)
# assert {node.name.value for node in nodes} == {"Bella", "Luna"}

async def test_get_one(self, client: InfrahubClient, base_dataset, cat_luna, person_sophia):
node1 = await client.get(kind=TESTING_CAT, id=cat_luna.id)
Expand Down

0 comments on commit d92173d

Please sign in to comment.