Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog

## 2.3.0
* Adds parent-tap-stream-id field to catalog for child streams [#84](https://github.com/singer-io/tap-intercom/pull/84)

## 2.2.3
* Fix pylint errors [#83](https://github.com/singer-io/tap-intercom/pull/83)

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from setuptools import setup, find_packages

setup(name='tap-intercom',
version='2.2.3',
version='2.3.0',
description='Singer.io tap for extracting data from the Intercom API',
author='jeff.huth@bytecode.io',
classifiers=['Programming Language :: Python :: 3 :: Only'],
Expand Down
5 changes: 5 additions & 0 deletions tap_intercom/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ def get_schemas():
)

mdata = metadata.to_map(mdata)
# Check if the stream has any parent attribute
parent_class = getattr(stream_object, 'parent', None)
if parent_class and hasattr(parent_class, 'tap_stream_id'):
parent_tap_stream_id = parent_class.tap_stream_id
mdata = metadata.write(mdata, (), 'parent-tap-stream-id', parent_tap_stream_id)

if stream_object.replication_key:
mdata = metadata.write(
Expand Down
4 changes: 4 additions & 0 deletions tests/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ class IntercomBaseTest(unittest.TestCase):
PRIMARY_KEYS = "table-key-properties"
FOREIGN_KEYS = "table-foreign-key-properties"
REPLICATION_METHOD = "forced-replication-method"
PARENT_TAP_STREAM_ID = "parent-tap-stream-id"
EXPECTED_PARENT_STREAM = "expected-parent-stream"
OBEYS_START_DATE = "obeys-start-date"
API_LIMIT = "max-row-limit"
INCREMENTAL = "INCREMENTAL"
Expand Down Expand Up @@ -80,6 +82,7 @@ def expected_metadata(self):
"admins": {
self.PRIMARY_KEYS: {"id"},
self.REPLICATION_METHOD: self.FULL_TABLE,
self.EXPECTED_PARENT_STREAM: "admin_list",
self.OBEYS_START_DATE : False
},
"companies": {
Expand Down Expand Up @@ -109,6 +112,7 @@ def expected_metadata(self):
self.PRIMARY_KEYS: {"id"},
self.REPLICATION_METHOD: self.INCREMENTAL,
self.REPLICATION_KEYS: {"updated_at"},
self.EXPECTED_PARENT_STREAM: "conversations",
self.OBEYS_START_DATE : True
},
"contact_attributes": {
Expand Down
14 changes: 14 additions & 0 deletions tests/test_intercom_discovery.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ def test_run(self):
expected_primary_keys = self.expected_primary_keys()[stream]
expected_replication_keys = self.expected_replication_keys()[stream]
expected_automatic_fields = expected_primary_keys | expected_replication_keys
expected_replication_method = self.expected_metadata()[stream].get(self.REPLICATION_METHOD)
expected_parent_stream = self.expected_metadata()[stream].get(self.EXPECTED_PARENT_STREAM)

# Collecting actual values...
schema_and_metadata = menagerie.get_annotated_schema(conn_id, catalog['stream_id'])
Expand All @@ -72,6 +74,12 @@ def test_run(self):
stream_properties[0].get(
"metadata", {self.REPLICATION_KEYS: []}).get(self.REPLICATION_KEYS, [])
)

actual_replication_method = stream_properties[0].get(
"metadata", {self.REPLICATION_METHOD: None}).get(self.REPLICATION_METHOD)

actual_parent_stream_id = stream_properties[0].get(
"metadata", {}).get(self.PARENT_TAP_STREAM_ID)
##########################################################################
### metadata assertions
##########################################################################
Expand Down Expand Up @@ -99,6 +107,12 @@ def test_run(self):
# are given the inclusion of automatic in metadata.
self.assertSetEqual(expected_automatic_fields, actual_automatic_fields)

# verify the replication method matches our expectations
self.assertEqual(expected_replication_method, actual_replication_method)

# verify parent-tap-stream-id for child streams
self.assertEqual(expected_parent_stream, actual_parent_stream_id)

# Verify that all other fields have an inclusion of available
# This assumes there are no unsupported fields for SaaS sources
self.assertTrue(
Expand Down