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

[TDL-24255] Fix for attribute & generated relationship name #32

Merged
merged 6 commits into from
Oct 10, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 1 addition & 8 deletions tap_outreach/sync.py
Expand Up @@ -250,14 +250,7 @@ def process_records(stream, mdata, max_modified, records, filter_field, fks):
raise Exception(
'null or `id` field expected for `data` relationship')

# potential fix for the issue - https://github.com/singer-io/tap-outreach/issues/20
if stream.tap_stream_id not in ["prospects", "events"]:
if fk_field_name in record_flat:
raise Exception('`{}` exists as both an attribute and generated relationship name'.format(fk_field_name))

if data_value is None:
record_flat[fk_field_name] = None
else:
if data_value is not None:
record_flat[fk_field_name] = data_value['id']

if filter_field in record_flat and record_flat[filter_field] > max_modified:
Expand Down
29 changes: 0 additions & 29 deletions tests/unittests/test_exception_handling.py
Expand Up @@ -89,32 +89,3 @@ def test_conflict_data_id(self):
self.assertEqual(
e.exception.args[0], "null or `id` field expected for `data` relationship"
)

def test_conflict_prospects_attributes(self):
"""call `process_records` function and by passing the `mock_id_records` in
the param.
We expect the exception to be raised -
``propId` exists as both an attribute and generated relationship name`
"""
mock_records = [
{
"id": 1,
"attributes": {"propId": 456},
"relationships": {"prop": {"data": {"id": 123}}},
}
]
mock_stream = MockStream()
mock_fks = ["propId"]
with self.assertRaises(Exception) as e:
process_records(
mock_stream,
"mock_mdata",
"mock_max_modified",
mock_records,
"mock_filter_field",
mock_fks,
)
self.assertEqual(
e.exception.args[0],
"`propId` exists as both an attribute and generated relationship name",
)