Skip to content

Commit

Permalink
Connector acceptance test: Fix oneof check (#22395)
Browse files Browse the repository at this point in the history
* fix oneof check

* adjust changelog

* adjust changelog
  • Loading branch information
Joe Reuter authored Feb 9, 2023
1 parent 9e8035c commit d82e01a
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -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)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down

0 comments on commit d82e01a

Please sign in to comment.