Skip to content
Merged
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
11 changes: 7 additions & 4 deletions tests/neo4j/datatypes/test_temporal_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@
)
from tests.neo4j.datatypes._util import TZ_IDS
from tests.neo4j.shared import get_server_info
from tests.shared import get_driver_name
from tests.shared import (
get_driver_name,
Potential,
)


class TestDataTypes(_TestTypesBase):
Expand Down Expand Up @@ -212,15 +215,15 @@ def work(tx):
cypher_dt = types.CypherDateTime(
y, mo, d, h, m, s, ns, offset, tz_id
)
if server_supports_utc == 1:
if server_supports_utc == Potential.YES:
# 5.0+ protocol sends date times in UTC
# => UTC times must be equal
assert_utc_equal(dt, cypher_dt)
elif server_supports_utc == 0:
elif server_supports_utc == Potential.NO:
# 4.2- protocol sends date times in wall clock time
# => Wall clock times must be equal
assert_wall_time_equal(dt, cypher_dt)
else:
else: # Potential.MAYBE
# 4.4 and 4.3 protocol sends date times in
# wall clock time or UTC depending on server version,
# driver version and their handshake.
Expand Down
9 changes: 6 additions & 3 deletions tests/neo4j/shared.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
Neo4j server, default "enterprise"
TEST_NEO4J_CLUSTER Whether the Neo4j server is a cluster, default "False"
"""


from functools import wraps
import os
import re
Expand All @@ -24,6 +26,7 @@
from nutkit.protocol import AuthorizationToken
from tests.shared import (
dns_resolve_single,
Potential,
TestkitTestCase,
)

Expand Down Expand Up @@ -128,10 +131,10 @@ def max_protocol_version(self):
@property
def has_utc_patch(self):
if self.version >= "5":
return 1
return Potential.YES
if self.version >= "4.3":
return 0.5 # maybe
return 0
return Potential.MAYBE
return Potential.NO


def get_server_info():
Expand Down
8 changes: 8 additions & 0 deletions tests/shared.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@


from contextlib import contextmanager
import enum
import functools
import inspect
import os
Expand Down Expand Up @@ -247,3 +248,10 @@ def subTest(self, **params): # noqa: N802
raise Exception("Should be SkipTest, or RunTest, "
"received {}: {}".format(type(response),
response))


class Potential(enum.Enum):
YES = 1.0
NO = 0.0
MAYBE = 0.5
# CAN_YOU_REPEAT_THE_QUESTION = "?"