-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* TDL-17000: fix breaking changes and TDL-17017: Fix bookmark for conversation_parts stream. (#45) * Reverted conversation_parts to full_table for parent as V1.1.3 * Updated bookmark test to handle conversation_parts * Updated comments * Added code to select parent_stream if only child stream is selected same as v1.1.3 * Added code comments * Resolved review comment * Resolved review comment * Added code comments * Added bookmark mechanism for conversation_parts same as before but independant of conversations * Added code comments * Added query paramater to get conversations greater and equal to bookmark * Adding changes of PR42 for better unit tests * Added logger messages * Added unit test * Updated unit test * Updated unit test * Updated variables in unit test * Added time_extracted for conversation_parts * Resolved review comments * Added companies to untestable for bookmark test * Reverted changes of last commit * Tdl 17003 Added back missing field for contact streams (#43) * Reverted the logic as per old version * Removed leads as well as it is not supported by tap * Tdl 17006 revert back companies to incremental (#44) * Reverted companies to incremental stream * Debuging integration test * Removed print statement * Added companies to untestable for bookmark test * TDL-17002: Make the logger messages more descriptive (#46) * added logger messages * removed unnecessary loggers * removed unnecessary loggers * updated the code to use stream name instead of parent stream name Co-authored-by: savan-chovatiya <80703490+savan-chovatiya@users.noreply.github.com> Co-authored-by: Umang Agrawal <80704207+umangagrawal-crest@users.noreply.github.com>
- Loading branch information
1 parent
1bf78ae
commit f78ec3a
Showing
8 changed files
with
188 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import unittest | ||
import singer | ||
from unittest import mock | ||
from tap_intercom.streams import ConversationParts | ||
from tap_intercom.client import IntercomClient | ||
|
||
class TestConversationPartsBookmarking(unittest.TestCase): | ||
|
||
@mock.patch("tap_intercom.streams.singer.write_bookmark", side_effect=singer.write_bookmark) | ||
@mock.patch("tap_intercom.streams.Conversations.get_records") | ||
@mock.patch("tap_intercom.client.IntercomClient.get") | ||
def test_conversation_parts_bookmarking(self, mocked_client_get, mocked_parent_records, mocked_write_bookmark): | ||
''' | ||
Verify that state is updated with parent's updated_at after syncing conversation_parts for each coversation. | ||
''' | ||
# Mocked parent records | ||
mocked_parent_records.return_value = [ | ||
{"id": 1, "updated_at": 1640636000}, # UTC datetime "2021-12-27T20:13:20.000000Z" for 1640636000 | ||
{"id": 2, "updated_at": 1640637000} # UTC datetime "2021-12-27T20:30:00.000000Z" for 1640637000 | ||
] | ||
# Mocked child records | ||
mocked_client_get.return_value = {} | ||
|
||
# Initialize IntercomClient and ConversationParts object | ||
client = IntercomClient('dummy_token', None) | ||
conversation_part = ConversationParts(client) | ||
|
||
# Call get_records() of conversation_parts which writes bookmark | ||
records = list(conversation_part.get_records({}, "test")) | ||
|
||
# Expected call of write_bookmark() function | ||
state = {'bookmarks': {'conversation_parts': {'updated_at': '2021-12-27T20:30:00.000000Z'}}} | ||
expected_write_bookmark = [ | ||
# Bookmark update after first parent(2021-12-27T20:13:20.000000Z) | ||
mock.call(state, 'conversation_parts', 'updated_at', '2021-12-27T20:13:20.000000Z'), | ||
# Bookmark update after second parent(2021-12-27T20:30:00.000000Z) | ||
mock.call(state, 'conversation_parts', 'updated_at', '2021-12-27T20:30:00.000000Z') | ||
] | ||
|
||
# Verify that write_bookmark() is called with expected values | ||
self.assertEquals(mocked_write_bookmark.mock_calls, expected_write_bookmark) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import unittest | ||
from tap_intercom.streams import BaseStream | ||
|
||
class TestEpochToDatetimeTransform(unittest.TestCase): | ||
|
||
def test_epoch_milliseconds_to_dt_str(self): | ||
""" | ||
Verify one epoch time with expected UTC datetime | ||
""" | ||
test_epoch = 1640760200000 | ||
expected_utc_datetime = "2021-12-29T06:43:20.000000Z" # expected UTC for `1640760200000` | ||
|
||
datetime_str = BaseStream.epoch_milliseconds_to_dt_str(test_epoch) | ||
|
||
# Verify that test epoch time is converted to valid UTC datetime | ||
self.assertEquals(datetime_str, expected_utc_datetime) |