Skip to content

Commit 5ab0b66

Browse files
committed
Fix some tests
1 parent aa3b4b4 commit 5ab0b66

File tree

2 files changed

+21
-10
lines changed

2 files changed

+21
-10
lines changed

backend/tests/unit/graphql/diff/test_diff_tree_query.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from datetime import datetime, timezone
12
from unittest.mock import AsyncMock
23

34
import pytest
@@ -20,6 +21,8 @@
2021
from infrahub.graphql.initialization import prepare_graphql_params
2122
from tests.helpers.graphql import graphql
2223

24+
UTC = timezone.utc # Required for older versions of Python
25+
2326
ADDED_ACTION = "ADDED"
2427
UPDATED_ACTION = "UPDATED"
2528
REMOVED_ACTION = "REMOVED"
@@ -779,12 +782,24 @@ async def test_diff_tree_summary_no_changes(
779782
[
780783
pytest.param(
781784
{},
782-
DiffSummaryCounters(num_added=2, num_updated=5, num_removed=2, from_time=Timestamp(), to_time=Timestamp()),
785+
DiffSummaryCounters(
786+
num_added=2,
787+
num_updated=5,
788+
num_removed=2,
789+
from_time=Timestamp(datetime.now(UTC).isoformat()),
790+
to_time=Timestamp(datetime.now(UTC).isoformat()),
791+
),
783792
id="no-filters",
784793
),
785794
pytest.param(
786795
{"kind": {"includes": ["TestThing"]}},
787-
DiffSummaryCounters(num_added=2, num_updated=1, num_removed=2, from_time=Timestamp(), to_time=Timestamp()),
796+
DiffSummaryCounters(
797+
num_added=2,
798+
num_updated=1,
799+
num_removed=2,
800+
from_time=Timestamp(datetime.now(UTC).isoformat()),
801+
to_time=Timestamp(datetime.now(UTC).isoformat()),
802+
),
788803
id="kind-includes",
789804
),
790805
],

backend/tests/unit/graphql/test_graphql_query.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2048,10 +2048,9 @@ async def test_query_node_updated_at(db: InfrahubDatabase, default_branch: Branc
20482048
assert result2.errors is None
20492049
assert result2.data["TestPerson"]["edges"][0]["node"]["_updated_at"]
20502050
assert result2.data["TestPerson"]["edges"][1]["node"]["_updated_at"]
2051-
assert (
2051+
assert result2.data["TestPerson"]["edges"][1]["node"]["_updated_at"] == Timestamp(
20522052
result2.data["TestPerson"]["edges"][1]["node"]["_updated_at"]
2053-
== Timestamp(result2.data["TestPerson"]["edges"][1]["node"]["_updated_at"]).to_string()
2054-
)
2053+
).to_string(with_z=False)
20552054
assert (
20562055
result2.data["TestPerson"]["edges"][0]["node"]["_updated_at"]
20572056
!= result2.data["TestPerson"]["edges"][1]["node"]["_updated_at"]
@@ -2125,12 +2124,9 @@ async def test_query_relationship_updated_at(db: InfrahubDatabase, default_branc
21252124
result2.data["TestPerson"]["edges"][0]["node"]["tags"]["edges"][0]["node"]["_updated_at"]
21262125
!= result2.data["TestPerson"]["edges"][0]["node"]["tags"]["edges"][0]["properties"]["updated_at"]
21272126
)
2128-
assert (
2127+
assert result2.data["TestPerson"]["edges"][0]["node"]["tags"]["edges"][0]["node"]["_updated_at"] == Timestamp(
21292128
result2.data["TestPerson"]["edges"][0]["node"]["tags"]["edges"][0]["node"]["_updated_at"]
2130-
== Timestamp(
2131-
result2.data["TestPerson"]["edges"][0]["node"]["tags"]["edges"][0]["node"]["_updated_at"]
2132-
).to_string()
2133-
)
2129+
).to_string(with_z=False)
21342130

21352131

21362132
async def test_query_attribute_node_property_source(

0 commit comments

Comments
 (0)