Skip to content

Commit

Permalink
improve robustness of check_if_cursor_field_was_changed
Browse files Browse the repository at this point in the history
  • Loading branch information
alafanechere committed Aug 22, 2022
1 parent 0873203 commit 3231e6d
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -228,5 +228,5 @@ 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."""
invalid_changes = {"values_changed", "iterable_item_added", "iterable_item_removed"}
if diff and set(diff.keys()).issubset(invalid_changes):
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 any([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,6 +1103,34 @@ 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 = [
Expand Down Expand Up @@ -1223,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 any([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 3231e6d

Please sign in to comment.