Skip to content

Commit

Permalink
SAT: improve check_if_cursor_field_was_changed to make it less stri…
Browse files Browse the repository at this point in the history
…ct (#15835)
  • Loading branch information
alafanechere authored Aug 22, 2022
1 parent 9879a81 commit 3ba8276
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog

## 0.2.2
Backward compatibility tests: improve `check_if_cursor_field_was_changed` to make it less radical and allow stream addition to catalog.[#15835](https://github.com/airbytehq/airbyte/pull/15835/)

## 0.2.1
Don't fail on updating `additionalProperties`: fix IndexError [#15532](https://github.com/airbytehq/airbyte/pull/15532/)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ COPY pytest.ini setup.py ./
COPY source_acceptance_test ./source_acceptance_test
RUN pip install .

LABEL io.airbyte.version=0.2.1
LABEL io.airbyte.version=0.2.2
LABEL io.airbyte.name=airbyte/source-acceptance-test

ENTRYPOINT ["python", "-m", "pytest", "-p", "source_acceptance_test.plugin", "-r", "fEsx"]
Original file line number Diff line number Diff line change
Expand Up @@ -227,5 +227,6 @@ def check_if_stream_was_removed(self, diff: DeepDiff):

def check_if_cursor_field_was_changed(self, diff: DeepDiff):
"""Check if a default cursor field value was changed."""
if diff:
invalid_changes = {"values_changed", "iterable_item_added", "iterable_item_removed"}
if any([change in invalid_changes for change in diff.keys()]):
self._raise_error("The value of 'default_cursor_field' was changed", diff)
Original file line number Diff line number Diff line change
Expand Up @@ -944,7 +944,7 @@ def as_pytest_param(self):
# Checking that all transitions in FAILING_SPEC_TRANSITIONS have should_fail == True to prevent typos
assert all([transition.should_fail for transition in FAILING_SPEC_TRANSITIONS])
# Checking that all transitions in VALID_SPEC_TRANSITIONS have should_fail = False to prevent typos
assert not all([transition.should_fail for transition in VALID_SPEC_TRANSITIONS])
assert all([not transition.should_fail for transition in VALID_SPEC_TRANSITIONS])

ALL_SPEC_TRANSITIONS_PARAMS = [transition.as_pytest_param() for transition in FAILING_SPEC_TRANSITIONS + VALID_SPEC_TRANSITIONS]

Expand Down Expand Up @@ -1103,9 +1103,63 @@ def test_validate_previous_configs(previous_connector_spec, actual_connector_spe
),
},
),
Transition(
name="Adding a stream but changing cursor should fail.",
should_fail=True,
previous={
"test_stream": AirbyteStream.parse_obj(
{
"name": "test_stream",
"json_schema": {"properties": {"user": {"type": "object", "properties": {"username": {"type": "string"}}}}},
"default_cursor_field": ["a"],
}
),
},
current={
"test_stream": AirbyteStream.parse_obj(
{
"name": "test_stream",
"json_schema": {"properties": {"user": {"type": "object", "properties": {"username": {"type": "string"}}}}},
"default_cursor_field": ["b"],
}
),
"other_test_stream": AirbyteStream.parse_obj(
{
"name": "other_test_stream",
"json_schema": {"properties": {"user": {"type": "object", "properties": {"username": {"type": "string"}}}}},
}
),
},
),
]

VALID_CATALOG_TRANSITIONS = [
Transition(
name="Adding a stream to a catalog should not fail.",
should_fail=False,
previous={
"test_stream": AirbyteStream.parse_obj(
{
"name": "test_stream",
"json_schema": {"properties": {"user": {"type": "object", "properties": {"username": {"type": "string"}}}}},
}
)
},
current={
"test_stream": AirbyteStream.parse_obj(
{
"name": "test_stream",
"json_schema": {"properties": {"user": {"type": "object", "properties": {"username": {"type": "string"}}}}},
}
),
"other_test_stream": AirbyteStream.parse_obj(
{
"name": "other_test_stream",
"json_schema": {"properties": {"user": {"type": "object", "properties": {"username": {"type": "string"}}}}},
}
),
},
),
Transition(
name="Making a field nullable should not fail.",
should_fail=False,
Expand Down Expand Up @@ -1197,7 +1251,7 @@ def test_validate_previous_configs(previous_connector_spec, actual_connector_spe
# Checking that all transitions in FAILING_CATALOG_TRANSITIONS have should_fail == True to prevent typos
assert all([transition.should_fail for transition in FAILING_CATALOG_TRANSITIONS])
# Checking that all transitions in VALID_CATALOG_TRANSITIONS have should_fail = False to prevent typos
assert not all([transition.should_fail for transition in VALID_CATALOG_TRANSITIONS])
assert all([not transition.should_fail for transition in VALID_CATALOG_TRANSITIONS])

ALL_CATALOG_TRANSITIONS_PARAMS = [transition.as_pytest_param() for transition in FAILING_CATALOG_TRANSITIONS + VALID_CATALOG_TRANSITIONS]

Expand Down

0 comments on commit 3ba8276

Please sign in to comment.