Skip to content

Commit efffd1a

Browse files
authored
Store driver features as enum entries (#290)
* Store driver features as enum entries This fixes an error in `tests.neo4j.test_summary.TestSummary.test_protocol_version_information` where computation of the expected negotiated bolt version relied on having enum entires available. * Fail hard on unknown driver features
1 parent 914f70c commit efffd1a

File tree

2 files changed

+21
-16
lines changed

2 files changed

+21
-16
lines changed

tests/neo4j/test_summary.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,8 @@ def test_protocol_version_information(self):
9494
if (f.name.startswith("BOLT_")
9595
and f.value.split(":")[-1] <= max_server_protocol_version)
9696
]
97+
if not common_protocol_versions:
98+
self.skipTest("Driver does not support server version.")
9799
common_max_version = max(common_protocol_versions)
98100
if common_max_version == "4.2":
99101
# Both versions are equivalent. Since 4.2 was introduced before

tests/shared.py

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -118,26 +118,27 @@ def get_driver_features(backend):
118118
response = backend.sendAndReceive(protocol.GetFeatures())
119119
if not isinstance(response, protocol.FeatureList):
120120
raise Exception("Response is not instance of FeatureList")
121-
features = set(response.features)
121+
raw_features = set(response.features)
122+
features = set()
123+
for raw in raw_features:
124+
features.add(protocol.Feature(raw))
122125
# TODO: remove this once all drivers manage the TLS feature flags
123126
# themselves.
124127
if get_driver_name() in ["java", "go"]:
125-
features.add(protocol.Feature.TLS_1_1.value)
128+
features.add(protocol.Feature.TLS_1_1)
126129
if get_driver_name() in ["java", "go", "dotnet"]:
127-
features.add(protocol.Feature.TLS_1_2.value)
130+
features.add(protocol.Feature.TLS_1_2)
128131
if get_driver_name() in ["go"]:
129-
features.add(protocol.Feature.TLS_1_3.value)
132+
features.add(protocol.Feature.TLS_1_3)
130133
if get_driver_name() in ["javascript", "go", "dotnet"]:
131-
features.add(
132-
f.value for f in (
133-
protocol.Feature.BOLT_3_0,
134-
protocol.Feature.BOLT_4_0,
135-
protocol.Feature.BOLT_4_1,
136-
protocol.Feature.BOLT_4_2,
137-
protocol.Feature.BOLT_4_3,
138-
protocol.Feature.BOLT_4_4,
139-
)
140-
)
134+
features.add((
135+
protocol.Feature.BOLT_3_0,
136+
protocol.Feature.BOLT_4_0,
137+
protocol.Feature.BOLT_4_1,
138+
protocol.Feature.BOLT_4_2,
139+
protocol.Feature.BOLT_4_3,
140+
protocol.Feature.BOLT_4_4,
141+
))
141142
print("features", features)
142143
return features
143144
except (OSError, protocol.BaseError) as e:
@@ -215,7 +216,7 @@ def setUp(self):
215216
response))
216217

217218
def driver_missing_features(self, *features):
218-
needed = set(map(lambda f: f.value, features))
219+
needed = set(features)
219220
supported = self._driver_features
220221
return needed - supported
221222

@@ -249,7 +250,9 @@ def driver_supports_bolt(self, version):
249250
def skip_if_missing_driver_features(self, *features):
250251
missing = self.driver_missing_features(*features)
251252
if missing:
252-
self.skipTest("Needs support for %s" % ", ".join(missing))
253+
self.skipTest("Needs support for %s" % ", ".join(
254+
map(str, missing)
255+
))
253256

254257
def skip_if_missing_bolt_support(self, version):
255258
self.skip_if_missing_driver_features(

0 commit comments

Comments
 (0)