Skip to content

Commit e37f409

Browse files
author
Joe Reuter
committed
fix fixture problem
1 parent 6e3809c commit e37f409

File tree

4 files changed

+31
-29
lines changed

4 files changed

+31
-29
lines changed

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
# Changelog
22

3+
## 0.5.0
4+
Re-release of 0.3.0 [#21451](https://github.com/airbytehq/airbyte/pull/21451)
5+
6+
## 0.4.0
7+
Revert 0.3.0
8+
39
## 0.3.0
4-
Add various stricter checks for specs (see PR for details). [#21451](https://github.com/airbytehq/airbyte/pull/21451)
10+
(Broken) Add various stricter checks for specs (see PR for details). [#21451](https://github.com/airbytehq/airbyte/pull/21451)
511

612
## 0.2.26
713
Check `future_state` only for incremental streams. [#21248](https://github.com/airbytehq/airbyte/pull/21248)

airbyte-integrations/bases/source-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 source_acceptance_test ./source_acceptance_test
3434
RUN pip install .
3535

36-
LABEL io.airbyte.version=0.3.0
36+
LABEL io.airbyte.version=0.5.0
3737
LABEL io.airbyte.name=airbyte/source-acceptance-test
3838

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

airbyte-integrations/bases/source-acceptance-test/source_acceptance_test/tests/test_core.py

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,6 @@ class TestSpec(BaseTest):
8686
spec_cache: ConnectorSpecification = None
8787
previous_spec_cache: ConnectorSpecification = None
8888

89-
@pytest.fixture(name="connection_specification", scope="class")
90-
def connection_specification_fixture(self, connector_spec_dict: dict) -> dict:
91-
return connector_spec_dict["connectionSpecification"]
92-
9389
@pytest.fixture(name="skip_backward_compatibility_tests")
9490
def skip_backward_compatibility_tests_fixture(
9591
self,
@@ -285,12 +281,12 @@ def _fail_on_errors(self, errors: List[str]):
285281
if len(errors) > 0:
286282
pytest.fail("\n".join(errors))
287283

288-
def test_property_type_is_not_array(self, connector_specification: dict):
284+
def test_property_type_is_not_array(self, connector_spec: ConnectorSpecification):
289285
"""
290286
Each field has one or multiple types, but the UI only supports a single type and optionally "null" as a second type.
291287
"""
292288
errors = []
293-
for type_path, type_value in dpath.util.search(connector_specification, "**/properties/*/type", yielded=True):
289+
for type_path, type_value in dpath.util.search(connector_spec.connectionSpecification, "**/properties/*/type", yielded=True):
294290
if isinstance(type_value, List):
295291
number_of_types = len(type_value)
296292
if number_of_types != 2 and number_of_types != 1:
@@ -303,14 +299,14 @@ def test_property_type_is_not_array(self, connector_specification: dict):
303299
)
304300
self._fail_on_errors(errors)
305301

306-
def test_object_not_empty(self, connector_specification: dict):
302+
def test_object_not_empty(self, connector_spec: ConnectorSpecification):
307303
"""
308304
Each object field needs to have at least one property as the UI won't be able to show them otherwise.
309305
If the whole spec is empty, it's allowed to have a single empty object at the top level
310306
"""
311-
schema_helper = JsonSchemaHelper(connector_specification)
307+
schema_helper = JsonSchemaHelper(connector_spec.connectionSpecification)
312308
errors = []
313-
for type_path, type_value in dpath.util.search(connector_specification, "**/type", yielded=True):
309+
for type_path, type_value in dpath.util.search(connector_spec.connectionSpecification, "**/type", yielded=True):
314310
if type_path == "type":
315311
# allow empty root object
316312
continue
@@ -322,13 +318,13 @@ def test_object_not_empty(self, connector_specification: dict):
322318
)
323319
self._fail_on_errors(errors)
324320

325-
def test_array_type(self, connector_specification: dict):
321+
def test_array_type(self, connector_spec: ConnectorSpecification):
326322
"""
327323
Each array has one or multiple types for its items, but the UI only supports a single type which can either be object, string or an enum
328324
"""
329-
schema_helper = JsonSchemaHelper(connector_specification)
325+
schema_helper = JsonSchemaHelper(connector_spec.connectionSpecification)
330326
errors = []
331-
for type_path, type_type in dpath.util.search(connector_specification, "**/type", yielded=True):
327+
for type_path, type_type in dpath.util.search(connector_spec.connectionSpecification, "**/type", yielded=True):
332328
property_definition = schema_helper.get_parent(type_path)
333329
if type_type != "array":
334330
# unrelated "items", not an array definition
@@ -342,7 +338,7 @@ def test_array_type(self, connector_specification: dict):
342338
errors.append(f"Items of {type_path} has to be either object or string or define an enum")
343339
self._fail_on_errors(errors)
344340

345-
def test_forbidden_complex_types(self, connector_specification: dict):
341+
def test_forbidden_complex_types(self, connector_spec: ConnectorSpecification):
346342
"""
347343
not, anyOf, patternProperties, prefixItems, allOf, if, then, else, dependentSchemas and dependentRequired are not allowed
348344
"""
@@ -360,25 +356,25 @@ def test_forbidden_complex_types(self, connector_specification: dict):
360356
]
361357
found_keys = set()
362358
for forbidden_key in forbidden_keys:
363-
for path, value in dpath.util.search(connector_specification, f"**/{forbidden_key}", yielded=True):
359+
for path, value in dpath.util.search(connector_spec.connectionSpecification, f"**/{forbidden_key}", yielded=True):
364360
found_keys.add(path)
365361

366362
for forbidden_key in forbidden_keys:
367363
# remove forbidden keys if they are used as properties directly
368-
for path, _value in dpath.util.search(connector_specification, f"**/properties/{forbidden_key}", yielded=True):
364+
for path, _value in dpath.util.search(connector_spec.connectionSpecification, f"**/properties/{forbidden_key}", yielded=True):
369365
found_keys.remove(path)
370366

371367
if len(found_keys) > 0:
372368
key_list = ", ".join(found_keys)
373369
pytest.fail(f"Found the following disallowed JSON schema features: {key_list}")
374370

375-
def test_date_pattern(self, connector_specification: dict, detailed_logger):
371+
def test_date_pattern(self, connector_spec: ConnectorSpecification, detailed_logger):
376372
"""
377373
Properties with format date or date-time should always have a pattern defined how the date/date-time should be formatted
378374
that corresponds with the format the datepicker component is creating.
379375
"""
380-
schema_helper = JsonSchemaHelper(connector_specification)
381-
for format_path, format in dpath.util.search(connector_specification, "**/format", yielded=True):
376+
schema_helper = JsonSchemaHelper(connector_spec.connectionSpecification)
377+
for format_path, format in dpath.util.search(connector_spec.connectionSpecification, "**/format", yielded=True):
382378
if not isinstance(format, str):
383379
# format is not a format definition here but a property named format
384380
continue
@@ -393,12 +389,12 @@ def test_date_pattern(self, connector_specification: dict, detailed_logger):
393389
f"{format_path} is defining a date-time format without the corresponding pattern Consider setting the pattern to {DATETIME_PATTERN} to make it easier for users to edit this field in the UI."
394390
)
395391

396-
def test_date_format(self, connector_specification: dict, detailed_logger):
392+
def test_date_format(self, connector_spec: ConnectorSpecification, detailed_logger):
397393
"""
398394
Properties with a pattern that looks like a date should have their format set to date or date-time.
399395
"""
400-
schema_helper = JsonSchemaHelper(connector_specification)
401-
for pattern_path, pattern in dpath.util.search(connector_specification, "**/pattern", yielded=True):
396+
schema_helper = JsonSchemaHelper(connector_spec.connectionSpecification)
397+
for pattern_path, pattern in dpath.util.search(connector_spec.connectionSpecification, "**/pattern", yielded=True):
402398
if not isinstance(pattern, str):
403399
# pattern is not a pattern definition here but a property named pattern
404400
continue

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -700,7 +700,7 @@ def test_airbyte_secret(mocker, connector_spec, should_fail):
700700
def test_property_type_is_not_array(mocker, connector_spec, should_fail):
701701
mocker.patch.object(conftest.pytest, "fail")
702702
t = _TestSpec()
703-
t.test_property_type_is_not_array(connector_spec)
703+
t.test_property_type_is_not_array(ConnectorSpecification(connectionSpecification=connector_spec))
704704
if should_fail:
705705
conftest.pytest.fail.assert_called_once()
706706
else:
@@ -750,7 +750,7 @@ def test_property_type_is_not_array(mocker, connector_spec, should_fail):
750750
def test_object_not_empty(mocker, connector_spec, should_fail):
751751
mocker.patch.object(conftest.pytest, "fail")
752752
t = _TestSpec()
753-
t.test_object_not_empty(connector_spec)
753+
t.test_object_not_empty(ConnectorSpecification(connectionSpecification=connector_spec))
754754
if should_fail:
755755
conftest.pytest.fail.assert_called_once()
756756
else:
@@ -781,7 +781,7 @@ def test_object_not_empty(mocker, connector_spec, should_fail):
781781
def test_array_type(mocker, connector_spec, should_fail):
782782
mocker.patch.object(conftest.pytest, "fail")
783783
t = _TestSpec()
784-
t.test_array_type(connector_spec)
784+
t.test_array_type(ConnectorSpecification(connectionSpecification=connector_spec))
785785
if should_fail:
786786
conftest.pytest.fail.assert_called_once()
787787
else:
@@ -818,7 +818,7 @@ def test_array_type(mocker, connector_spec, should_fail):
818818
def test_forbidden_complex_types(mocker, connector_spec, should_fail):
819819
mocker.patch.object(conftest.pytest, "fail")
820820
t = _TestSpec()
821-
t.test_forbidden_complex_types(connector_spec)
821+
t.test_forbidden_complex_types(ConnectorSpecification(connectionSpecification=connector_spec))
822822
if should_fail:
823823
conftest.pytest.fail.assert_called_once()
824824
else:
@@ -862,7 +862,7 @@ def test_date_pattern(mocker, connector_spec, is_warning_logged):
862862
mocker.patch.object(conftest.pytest, "fail")
863863
logger = mocker.Mock()
864864
t = _TestSpec()
865-
t.test_date_pattern(connector_spec, logger)
865+
t.test_date_pattern(ConnectorSpecification(connectionSpecification=connector_spec), logger)
866866
conftest.pytest.fail.assert_not_called()
867867
if is_warning_logged:
868868
_, args, _ = logger.warning.mock_calls[0]
@@ -907,7 +907,7 @@ def test_date_format(mocker, connector_spec, is_warning_logged):
907907
mocker.patch.object(conftest.pytest, "fail")
908908
logger = mocker.Mock()
909909
t = _TestSpec()
910-
t.test_date_format(connector_spec, logger)
910+
t.test_date_format(ConnectorSpecification(connectionSpecification=connector_spec), logger)
911911
conftest.pytest.fail.assert_not_called()
912912
if is_warning_logged:
913913
_, args, _ = logger.warning.mock_calls[0]

0 commit comments

Comments
 (0)