Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Connector acceptance test: Fix oneof check #22395

Merged
merged 9 commits into from
Feb 9, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog

## 0.5.1
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)

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.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"]
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