Skip to content

Commit 5909d77

Browse files
author
Marius Posta
authored
connector acceptance tests: relax test_oneof_usage const criteria (#44540)
1 parent dbf4834 commit 5909d77

File tree

6 files changed

+50
-22
lines changed

6 files changed

+50
-22
lines changed

airbyte-ci/connectors/live-tests/README.md

+4
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,10 @@ The traffic recorded on the control connector is passed to the target connector
279279

280280
## Changelog
281281

282+
### 0.18.5
283+
284+
Relax test_oneof_usage criteria for constant value definitions in connector SPEC output.
285+
282286
### 0.18.4
283287

284288
Bugfix: Use connection-retriever 0.7.2

airbyte-ci/connectors/live-tests/pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"
44

55
[tool.poetry]
66
name = "live-tests"
7-
version = "0.18.4"
7+
version = "0.18.5"
88
description = "Contains utilities for testing connectors against live data."
99
authors = ["Airbyte <[email protected]>"]
1010
license = "MIT"

airbyte-ci/connectors/live-tests/src/live_tests/validation_tests/test_spec.py

+20-10
Original file line numberDiff line numberDiff line change
@@ -112,22 +112,32 @@ async def test_oneof_usage(target_spec: ConnectorSpecification):
112112
assert common_props, f"There should be at least one common property for {oneof_path} subobjects. {docs_msg}"
113113

114114
const_common_props = set()
115+
enum_common_props = set()
115116
for common_prop in common_props:
116117
if all(["const" in variant["properties"][common_prop] for variant in variants]):
117118
const_common_props.add(common_prop)
118-
assert (
119-
len(const_common_props) == 1
120-
), f"There should be exactly one common property with 'const' keyword for {oneof_path} subobjects. {docs_msg}"
119+
if all(["enum" in variant["properties"][common_prop] for variant in variants]):
120+
enum_common_props.add(common_prop)
121+
assert len(const_common_props) == 1 or (
122+
len(const_common_props) == 0 and len(enum_common_props) == 1
123+
), f"There should be exactly one common property with 'const' keyword (or equivalent) for {oneof_path} subobjects. {docs_msg}"
121124

122-
const_common_prop = const_common_props.pop()
125+
const_common_prop = const_common_props.pop() if const_common_props else enum_common_props.pop()
123126
for n, variant in enumerate(variants):
124127
prop_obj = variant["properties"][const_common_prop]
125-
assert (
126-
"default" not in prop_obj or prop_obj["default"] == prop_obj["const"]
127-
), f"'default' needs to be identical to const in common property {oneof_path}[{n}].{const_common_prop}. It's recommended to just use `const`. {docs_msg}"
128-
assert "enum" not in prop_obj or (
129-
len(prop_obj["enum"]) == 1 and prop_obj["enum"][0] == prop_obj["const"]
130-
), f"'enum' needs to be an array with a single item identical to const in common property {oneof_path}[{n}].{const_common_prop}. It's recommended to just use `const`. {docs_msg}"
128+
prop_info = f"common property {oneof_path}[{n}].{const_common_prop}. It's recommended to just use `const`."
129+
if "const" in prop_obj:
130+
const_value = prop_obj["const"]
131+
assert (
132+
"default" not in prop_obj or prop_obj["default"] == const_value
133+
), f"'default' needs to be identical to 'const' in {prop_info}. {docs_msg}"
134+
assert "enum" not in prop_obj or prop_obj["enum"] == [
135+
const_value
136+
], f"'enum' needs to be an array with a single item identical to 'const' in {prop_info}. {docs_msg}"
137+
else:
138+
assert (
139+
"enum" in prop_obj and "default" in prop_obj and prop_obj["enum"] == [prop_obj["default"]]
140+
), f"'enum' needs to be an array with a single item identical to 'default' in {prop_info}. {docs_msg}"
131141

132142

133143
def _is_spec_property_name_secret(path: str, secret_property_names) -> Tuple[Optional[str], bool]:

airbyte-integrations/bases/connector-acceptance-test/CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## 3.9.2
4+
5+
Relax test_oneof_usage criteria for constant value definitions.
6+
37
## 3.9.1
48

59
Bug fixes for dagger execution caching and for failure trace message test case.

airbyte-integrations/bases/connector-acceptance-test/connector_acceptance_test/tests/test_core.py

+20-10
Original file line numberDiff line numberDiff line change
@@ -197,22 +197,32 @@ def test_oneof_usage(self, actual_connector_spec: ConnectorSpecification):
197197
assert common_props, f"There should be at least one common property for {oneof_path} subobjects. {docs_msg}"
198198

199199
const_common_props = set()
200+
enum_common_props = set()
200201
for common_prop in common_props:
201202
if all(["const" in variant["properties"][common_prop] for variant in variants]):
202203
const_common_props.add(common_prop)
203-
assert (
204-
len(const_common_props) == 1
205-
), f"There should be exactly one common property with 'const' keyword for {oneof_path} subobjects. {docs_msg}"
204+
if all(["enum" in variant["properties"][common_prop] for variant in variants]):
205+
enum_common_props.add(common_prop)
206+
assert len(const_common_props) == 1 or (
207+
len(const_common_props) == 0 and len(enum_common_props) == 1
208+
), f"There should be exactly one common property with 'const' keyword (or equivalent) for {oneof_path} subobjects. {docs_msg}"
206209

207-
const_common_prop = const_common_props.pop()
210+
const_common_prop = const_common_props.pop() if const_common_props else enum_common_props.pop()
208211
for n, variant in enumerate(variants):
209212
prop_obj = variant["properties"][const_common_prop]
210-
assert (
211-
"default" not in prop_obj or prop_obj["default"] == prop_obj["const"]
212-
), f"'default' needs to be identical to const in common property {oneof_path}[{n}].{const_common_prop}. It's recommended to just use `const`. {docs_msg}"
213-
assert "enum" not in prop_obj or (
214-
len(prop_obj["enum"]) == 1 and prop_obj["enum"][0] == prop_obj["const"]
215-
), f"'enum' needs to be an array with a single item identical to const in common property {oneof_path}[{n}].{const_common_prop}. It's recommended to just use `const`. {docs_msg}"
213+
prop_info = f"common property {oneof_path}[{n}].{const_common_prop}. It's recommended to just use `const`."
214+
if "const" in prop_obj:
215+
const_value = prop_obj["const"]
216+
assert (
217+
"default" not in prop_obj or prop_obj["default"] == const_value
218+
), f"'default' needs to be identical to 'const' in {prop_info}. {docs_msg}"
219+
assert "enum" not in prop_obj or prop_obj["enum"] == [
220+
const_value
221+
], f"'enum' needs to be an array with a single item identical to 'const' in {prop_info}. {docs_msg}"
222+
else:
223+
assert (
224+
"enum" in prop_obj and "default" in prop_obj and prop_obj["enum"] == [prop_obj["default"]]
225+
), f"'enum' needs to be an array with a single item identical to 'default' in {prop_info}. {docs_msg}"
216226

217227
def test_required(self):
218228
"""Check that connector will fail if any required field is missing"""

airbyte-integrations/bases/connector-acceptance-test/pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"
44

55
[tool.poetry]
66
name = "connector-acceptance-test"
7-
version = "3.9.1"
7+
version = "3.9.2"
88
description = "Contains acceptance tests for connectors."
99
authors = ["Airbyte <[email protected]>"]
1010
license = "MIT"

0 commit comments

Comments
 (0)