-
Notifications
You must be signed in to change notification settings - Fork 39
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-15454 removed the buffer system #77
Open
namrata270998
wants to merge
12
commits into
master
Choose a base branch
from
TDL-15454-remove-buffer-from-tickets
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 4 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
11bcae7
removed the buffer systesm
namrata270998 f6e291e
removed the unnecessary methods
namrata270998 7ec3d40
fixed pylint errors
namrata270998 cf474f5
resolved pylint errors
namrata270998 abfb08a
added comments in test file
namrata270998 1020062
Added coverage report
prijendev 63b6c71
added comment
namrata270998 fa665d0
Merge branch 'TDL-15454-remove-buffer-from-tickets' of https://github…
namrata270998 5d4a2d5
added logger for printingcount of child streams
namrata270998 3993272
updated unittest
namrata270998 6ea6e17
Tdl 14803 check api access in discovery mode (#84)
prijendev 2728232
Merge branch 'TDL-14624-crest-master' into TDL-15454-remove-buffer-fr…
prijendev File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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,163 @@ | ||
from tap_zendesk import LOGGER, oauth_auth | ||
import unittest | ||
from unittest import mock | ||
from unittest.mock import patch | ||
from tap_zendesk.streams import Stream, Tickets, zendesk_metrics | ||
from tap_zendesk.sync import sync_stream | ||
from tap_zendesk import Zenpy | ||
import json | ||
|
||
class Zenpy(): | ||
def __init__(self) -> None: | ||
pass | ||
|
||
def mocked_sync_audits(ticket_id=None): | ||
ticket_audits = [ | ||
{ | ||
"author_id":387494208358, | ||
"created_at":"2021-10-11T12:23:20.000000Z", | ||
"id":910518732098, | ||
"ticket_id":2 | ||
}, | ||
{ | ||
"author_id":387494208358, | ||
"created_at":"2021-10-11T12:24:05.000000Z", | ||
"id":910519204898, | ||
"ticket_id":2, | ||
} | ||
] | ||
for audit in ticket_audits: | ||
yield ('ticket_audits', audit) | ||
|
||
def mocked_sync_metrics(ticket_id=None): | ||
ticket_metrics = [ | ||
{ | ||
"author_id":387494208358, | ||
"created_at":"2021-10-11T12:23:20.000000Z", | ||
"id":910518732090, | ||
"ticket_id":2 | ||
}, | ||
{ | ||
"author_id":387494208358, | ||
"created_at":"2021-10-11T12:24:05.000000Z", | ||
"id":910519204892, | ||
"ticket_id":2, | ||
} | ||
] | ||
for metric in ticket_metrics: | ||
yield ('ticket_metrics', metric) | ||
|
||
def mocked_sync_comments(ticket_id=None): | ||
ticket_comments = [ | ||
{ | ||
"author_id":387494208356, | ||
"created_at":"2021-10-11T12:23:20.000000Z", | ||
"id":910518732090, | ||
"ticket_id":2 | ||
}, | ||
{ | ||
"author_id":387494208354, | ||
"created_at":"2021-10-11T12:24:05.000000Z", | ||
"id":910519204892, | ||
"ticket_id":2, | ||
} | ||
] | ||
for comment in ticket_comments: | ||
yield ('ticket_comments', comment) | ||
|
||
@mock.patch('tap_zendesk.streams.Stream.update_bookmark') | ||
@mock.patch('tap_zendesk.streams.Stream.get_bookmark') | ||
@mock.patch('tap_zendesk.streams.TicketAudits.is_selected') | ||
@mock.patch('tap_zendesk.streams.TicketMetrics.is_selected') | ||
@mock.patch('tap_zendesk.streams.TicketComments.is_selected') | ||
@mock.patch('tap_zendesk.streams.TicketAudits.sync') | ||
@mock.patch('tap_zendesk.streams.TicketMetrics.sync') | ||
@mock.patch('tap_zendesk.streams.TicketComments.sync') | ||
@mock.patch('tap_zendesk.streams.CursorBasedExportStream.get_objects') | ||
def test_yield_records(mock_objects, mock_comments_sync, mock_metrics_sync, mock_audits_sync, mock_comments, mock_metrics, mock_audits, mock_get_bookmark, mock_update_bookmark): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please add comments in unit test There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
ticket_stream = Tickets(Zenpy(), {}) | ||
tickets = [{ | ||
"url":"https://talend1234.zendesk.com/api/v2/tickets/1.json", | ||
"id":2, | ||
"external_id":"None", | ||
"created_at":"2021-10-11T12:12:31Z", | ||
"updated_at":"2021-10-12T08:37:28Z", | ||
"requester_id":387331462257, | ||
"submitter_id":387494208358, | ||
"assignee_id":387494208358, | ||
"organization_id":"None", | ||
"group_id":360010350357, | ||
"due_at":"None", | ||
"ticket_form_id":360003740737, | ||
"brand_id":360004806057, | ||
"generated_timestamp":1634027848, | ||
"fields": [] | ||
}] | ||
mock_objects.return_value = tickets | ||
expected_audits = [ | ||
{ | ||
"author_id":387494208358, | ||
"created_at":"2021-10-11T12:23:20.000000Z", | ||
"id":910518732098, | ||
"ticket_id":2 | ||
}, | ||
{ | ||
"author_id":387494208358, | ||
"created_at":"2021-10-11T12:24:05.000000Z", | ||
"id":910519204898, | ||
"ticket_id":2, | ||
} | ||
] | ||
expected_metrics = [ | ||
{ | ||
"author_id":387494208358, | ||
"created_at":"2021-10-11T12:23:20.000000Z", | ||
"id":910518732090, | ||
"ticket_id":2 | ||
}, | ||
{ | ||
"author_id":387494208358, | ||
"created_at":"2021-10-11T12:24:05.000000Z", | ||
"id":910519204892, | ||
"ticket_id":2, | ||
} | ||
] | ||
expected_comments = [ | ||
{ | ||
"author_id":387494208356, | ||
"created_at":"2021-10-11T12:23:20.000000Z", | ||
"id":910518732090, | ||
"ticket_id":2 | ||
}, | ||
{ | ||
"author_id":387494208354, | ||
"created_at":"2021-10-11T12:24:05.000000Z", | ||
"id":910519204892, | ||
"ticket_id":2, | ||
} | ||
] | ||
mock_metrics.return_value = True | ||
mock_audits.return_value = True | ||
mock_comments.return_value = True | ||
mock_update_bookmark.side_effect = None | ||
mock_metrics_sync.side_effect = mocked_sync_metrics | ||
mock_audits_sync.side_effect = mocked_sync_audits | ||
mock_comments_sync.side_effect = mocked_sync_comments | ||
|
||
expected_tickets = list(ticket_stream.sync(state={})) | ||
audits = [] | ||
metrics = [] | ||
comments = [] | ||
|
||
for count, each in enumerate(expected_tickets): | ||
if count == 0: | ||
continue | ||
if each[0] == 'ticket_audits': | ||
audits.append(each[1]) | ||
if each[0] == 'ticket_metrics': | ||
metrics.append(each[1]) | ||
if each[0] == 'ticket_comments': | ||
comments.append(each[1]) | ||
assert expected_audits == audits | ||
assert expected_metrics == metrics | ||
assert expected_comments == comments |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason for yielding self.stream? instead of just ticket
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
because the buffer_records also had self.stream passed as an argument. And it helps in identifying which stream is yielded.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes because earlier it is required to identify the stream in function
_buffer_record
as there is login on the stream name, I don't see that logic now, do we still need this?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added a comment regarding why we are yielding stream name and rec in the code