diff --git a/airbyte-integrations/bases/connector-acceptance-test/CHANGELOG.md b/airbyte-integrations/bases/connector-acceptance-test/CHANGELOG.md index 71fa7b3f0b8b..d66d00adc0c2 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.3 +Spec tests: Make `oneOf` checks work for nested `oneOf`s. [#22395](https://github.com/airbytehq/airbyte/pull/22395) + ## 0.5.2 Check that `emitted_at` increases during subsequent reads. [#22291](https://github.com/airbytehq/airbyte/pull/22291) diff --git a/airbyte-integrations/bases/connector-acceptance-test/Dockerfile b/airbyte-integrations/bases/connector-acceptance-test/Dockerfile index 44c2b694f50f..6c35d67a2942 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.2 +LABEL io.airbyte.version=0.5.3 LABEL io.airbyte.name=airbyte/connector-acceptance-test ENTRYPOINT ["python", "-m", "pytest", "-p", "connector_acceptance_test.plugin", "-r", "fEsx"] 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 20c878c9fbb6..546f51557c41 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 140f678a96a4..3f5489969263 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 93dc0de58c99..1619cc6dd5ce 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": {