From 8e680c9ff767e3a93e90792f650f3dedd1df19ba Mon Sep 17 00:00:00 2001 From: Joe Reuter Date: Sun, 5 Feb 2023 14:59:31 -0800 Subject: [PATCH 1/3] fix oneof check --- .../tests/test_core.py | 2 +- .../utils/json_schema_helper.py | 4 +- .../unit_tests/test_spec.py | 74 +++++++++++++++++++ 3 files changed, 77 insertions(+), 3 deletions(-) diff --git a/airbyte-integrations/bases/connector-acceptance-test/connector_acceptance_test/tests/test_core.py b/airbyte-integrations/bases/connector-acceptance-test/connector_acceptance_test/tests/test_core.py index 31a56f5728b8..09119109112c 100644 --- a/airbyte-integrations/bases/connector-acceptance-test/connector_acceptance_test/tests/test_core.py +++ b/airbyte-integrations/bases/connector-acceptance-test/connector_acceptance_test/tests/test_core.py @@ -165,7 +165,7 @@ def test_oneof_usage(self, actual_connector_spec: ConnectorSpecification): for variant in variants: assert "properties" in variant, f"Each item in the oneOf array should be a property with type object. {docs_msg}" - oneof_path = ".".join(variant_path) + oneof_path = ".".join(map(str, variant_path)) variant_props = [set(v["properties"].keys()) for v in variants] common_props = set.intersection(*variant_props) assert common_props, f"There should be at least one common property for {oneof_path} subobjects. {docs_msg}" diff --git a/airbyte-integrations/bases/connector-acceptance-test/connector_acceptance_test/utils/json_schema_helper.py b/airbyte-integrations/bases/connector-acceptance-test/connector_acceptance_test/utils/json_schema_helper.py index 400b5af53b6d..d692825e0d3a 100644 --- a/airbyte-integrations/bases/connector-acceptance-test/connector_acceptance_test/utils/json_schema_helper.py +++ b/airbyte-integrations/bases/connector-acceptance-test/connector_acceptance_test/utils/json_schema_helper.py @@ -109,7 +109,7 @@ def field(self, path: List[str]) -> CatalogField: """ return CatalogField(schema=self.get_property(path), path=path) - def get_node(self, path: List[str]) -> Any: + def get_node(self, path: List[Union[str, int]]) -> Any: """Return part of schema by specified path :param path: list of fields in the order of navigation @@ -132,7 +132,7 @@ def get_parent(self, path: str) -> Any: return self._schema return dpath.util.get(self._schema, parent_path) - def find_nodes(self, keys: List[str]) -> List[List[str]]: + def find_nodes(self, keys: List[str]) -> List[List[Union[str, int]]]: """Find all paths that lead to nodes with the specified keys. :param keys: list of keys diff --git a/airbyte-integrations/bases/connector-acceptance-test/unit_tests/test_spec.py b/airbyte-integrations/bases/connector-acceptance-test/unit_tests/test_spec.py index 93f1a8c2c93e..923e394b379c 100644 --- a/airbyte-integrations/bases/connector-acceptance-test/unit_tests/test_spec.py +++ b/airbyte-integrations/bases/connector-acceptance-test/unit_tests/test_spec.py @@ -190,6 +190,80 @@ def parametrize_test_case(*test_cases: Dict[str, Any]) -> Callable: }, "should_fail": False, }, + { + "test_id": "all_good_nested", + "connector_spec": { + "type": "object", + "properties": { + "select_type": { + "type": "object", + "oneOf": [ + { + "type": "object", + "properties": { + "option_title": {"type": "string", "title": "Title", "const": "first option"}, + "something": {"type": "string"}, + "nest": { + "type": "object", + "oneOf": [ + {"type": "object", "properties": {"t": {"type": "string", "const": "A"}}}, + {"type": "object", "properties": {"t": {"type": "string", "const": "B"}}}, + ], + }, + }, + }, + { + "type": "object", + "properties": { + "option_title": {"type": "string", "title": "Title", "const": "second option"}, + "some_field": {"type": "boolean"}, + }, + }, + ], + }, + "client_secret": {"type": "string"}, + "access_token": {"type": "string"}, + }, + }, + "should_fail": False, + }, + { + "test_id": "fail_nested", + "connector_spec": { + "type": "object", + "properties": { + "select_type": { + "type": "object", + "oneOf": [ + { + "type": "object", + "properties": { + "option_title": {"type": "string", "title": "Title", "const": "first option"}, + "something": {"type": "string"}, + "nest": { + "type": "object", + "oneOf": [ + {"type": "object", "properties": {"t": {"type": "string", "const": "A"}}}, + {"type": "string"}, + ], + }, + }, + }, + { + "type": "object", + "properties": { + "option_title": {"type": "string", "title": "Title", "const": "second option"}, + "some_field": {"type": "boolean"}, + }, + }, + ], + }, + "client_secret": {"type": "string"}, + "access_token": {"type": "string"}, + }, + }, + "should_fail": True, + }, { "test_id": "top_level_node_is_not_of_object_type", "connector_spec": { From 2c9a1d7a7a0255f0881c5a315ab2c613dfa49555 Mon Sep 17 00:00:00 2001 From: Joe Reuter Date: Sun, 5 Feb 2023 15:02:13 -0800 Subject: [PATCH 2/3] adjust changelog --- .../bases/connector-acceptance-test/CHANGELOG.md | 3 +++ .../bases/connector-acceptance-test/Dockerfile | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/airbyte-integrations/bases/connector-acceptance-test/CHANGELOG.md b/airbyte-integrations/bases/connector-acceptance-test/CHANGELOG.md index 0d9294c96eba..c3d099c42b23 100644 --- a/airbyte-integrations/bases/connector-acceptance-test/CHANGELOG.md +++ b/airbyte-integrations/bases/connector-acceptance-test/CHANGELOG.md @@ -1,5 +1,8 @@ # Changelog +## 0.5.1 +Make `oneOf` checks work for nested `oneOf`s. [#22395](https://github.com/airbytehq/airbyte/pull/22395) + ## 0.5.0 Re-release of 0.3.0 [#21451](https://github.com/airbytehq/airbyte/pull/21451) diff --git a/airbyte-integrations/bases/connector-acceptance-test/Dockerfile b/airbyte-integrations/bases/connector-acceptance-test/Dockerfile index cfed93a37001..a198c17604b1 100644 --- a/airbyte-integrations/bases/connector-acceptance-test/Dockerfile +++ b/airbyte-integrations/bases/connector-acceptance-test/Dockerfile @@ -33,7 +33,7 @@ COPY pytest.ini setup.py ./ COPY connector_acceptance_test ./connector_acceptance_test RUN pip install . -LABEL io.airbyte.version=0.5.0 +LABEL io.airbyte.version=0.5.1 LABEL io.airbyte.name=airbyte/connector-acceptance-test ENTRYPOINT ["python", "-m", "pytest", "-p", "connector_acceptance_test.plugin", "-r", "fEsx"] From 447603bbb325620b0853bc4cf871379d9f14e555 Mon Sep 17 00:00:00 2001 From: Joe Reuter Date: Sun, 5 Feb 2023 15:21:32 -0800 Subject: [PATCH 3/3] adjust changelog --- .../bases/connector-acceptance-test/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/airbyte-integrations/bases/connector-acceptance-test/CHANGELOG.md b/airbyte-integrations/bases/connector-acceptance-test/CHANGELOG.md index c3d099c42b23..c0268ee9d2bf 100644 --- a/airbyte-integrations/bases/connector-acceptance-test/CHANGELOG.md +++ b/airbyte-integrations/bases/connector-acceptance-test/CHANGELOG.md @@ -1,7 +1,7 @@ # Changelog ## 0.5.1 -Make `oneOf` checks work for nested `oneOf`s. [#22395](https://github.com/airbytehq/airbyte/pull/22395) +Spec tests: Make `oneOf` checks work for nested `oneOf`s. [#22395](https://github.com/airbytehq/airbyte/pull/22395) ## 0.5.0 Re-release of 0.3.0 [#21451](https://github.com/airbytehq/airbyte/pull/21451)