Skip to content

Commit d82e01a

Browse files
author
Joe Reuter
authored
Connector acceptance test: Fix oneof check (#22395)
* fix oneof check * adjust changelog * adjust changelog
1 parent 9e8035c commit d82e01a

File tree

5 files changed

+81
-4
lines changed

5 files changed

+81
-4
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Changelog
22

3+
## 0.5.3
4+
Spec tests: Make `oneOf` checks work for nested `oneOf`s. [#22395](https://github.com/airbytehq/airbyte/pull/22395)
5+
36
## 0.5.2
47
Check that `emitted_at` increases during subsequent reads. [#22291](https://github.com/airbytehq/airbyte/pull/22291)
58

airbyte-integrations/bases/connector-acceptance-test/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ COPY pytest.ini setup.py ./
3333
COPY connector_acceptance_test ./connector_acceptance_test
3434
RUN pip install .
3535

36-
LABEL io.airbyte.version=0.5.2
36+
LABEL io.airbyte.version=0.5.3
3737
LABEL io.airbyte.name=airbyte/connector-acceptance-test
3838

3939
ENTRYPOINT ["python", "-m", "pytest", "-p", "connector_acceptance_test.plugin", "-r", "fEsx"]

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ def test_oneof_usage(self, actual_connector_spec: ConnectorSpecification):
165165
for variant in variants:
166166
assert "properties" in variant, f"Each item in the oneOf array should be a property with type object. {docs_msg}"
167167

168-
oneof_path = ".".join(variant_path)
168+
oneof_path = ".".join(map(str, variant_path))
169169
variant_props = [set(v["properties"].keys()) for v in variants]
170170
common_props = set.intersection(*variant_props)
171171
assert common_props, f"There should be at least one common property for {oneof_path} subobjects. {docs_msg}"

airbyte-integrations/bases/connector-acceptance-test/connector_acceptance_test/utils/json_schema_helper.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ def field(self, path: List[str]) -> CatalogField:
109109
"""
110110
return CatalogField(schema=self.get_property(path), path=path)
111111

112-
def get_node(self, path: List[str]) -> Any:
112+
def get_node(self, path: List[Union[str, int]]) -> Any:
113113
"""Return part of schema by specified path
114114
115115
:param path: list of fields in the order of navigation
@@ -132,7 +132,7 @@ def get_parent(self, path: str) -> Any:
132132
return self._schema
133133
return dpath.util.get(self._schema, parent_path)
134134

135-
def find_nodes(self, keys: List[str]) -> List[List[str]]:
135+
def find_nodes(self, keys: List[str]) -> List[List[Union[str, int]]]:
136136
"""Find all paths that lead to nodes with the specified keys.
137137
138138
:param keys: list of keys

airbyte-integrations/bases/connector-acceptance-test/unit_tests/test_spec.py

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,80 @@ def parametrize_test_case(*test_cases: Dict[str, Any]) -> Callable:
190190
},
191191
"should_fail": False,
192192
},
193+
{
194+
"test_id": "all_good_nested",
195+
"connector_spec": {
196+
"type": "object",
197+
"properties": {
198+
"select_type": {
199+
"type": "object",
200+
"oneOf": [
201+
{
202+
"type": "object",
203+
"properties": {
204+
"option_title": {"type": "string", "title": "Title", "const": "first option"},
205+
"something": {"type": "string"},
206+
"nest": {
207+
"type": "object",
208+
"oneOf": [
209+
{"type": "object", "properties": {"t": {"type": "string", "const": "A"}}},
210+
{"type": "object", "properties": {"t": {"type": "string", "const": "B"}}},
211+
],
212+
},
213+
},
214+
},
215+
{
216+
"type": "object",
217+
"properties": {
218+
"option_title": {"type": "string", "title": "Title", "const": "second option"},
219+
"some_field": {"type": "boolean"},
220+
},
221+
},
222+
],
223+
},
224+
"client_secret": {"type": "string"},
225+
"access_token": {"type": "string"},
226+
},
227+
},
228+
"should_fail": False,
229+
},
230+
{
231+
"test_id": "fail_nested",
232+
"connector_spec": {
233+
"type": "object",
234+
"properties": {
235+
"select_type": {
236+
"type": "object",
237+
"oneOf": [
238+
{
239+
"type": "object",
240+
"properties": {
241+
"option_title": {"type": "string", "title": "Title", "const": "first option"},
242+
"something": {"type": "string"},
243+
"nest": {
244+
"type": "object",
245+
"oneOf": [
246+
{"type": "object", "properties": {"t": {"type": "string", "const": "A"}}},
247+
{"type": "string"},
248+
],
249+
},
250+
},
251+
},
252+
{
253+
"type": "object",
254+
"properties": {
255+
"option_title": {"type": "string", "title": "Title", "const": "second option"},
256+
"some_field": {"type": "boolean"},
257+
},
258+
},
259+
],
260+
},
261+
"client_secret": {"type": "string"},
262+
"access_token": {"type": "string"},
263+
},
264+
},
265+
"should_fail": True,
266+
},
193267
{
194268
"test_id": "top_level_node_is_not_of_object_type",
195269
"connector_spec": {

0 commit comments

Comments
 (0)