-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Source Zendesk Support: increase test coverage (#32440)
Co-authored-by: roman-yermilov-gl <[email protected]>
- Loading branch information
1 parent
4561792
commit 4df8096
Showing
6 changed files
with
57 additions
and
72 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
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 |
---|---|---|
|
@@ -22,6 +22,10 @@ | |
END_OF_STREAM_KEY, | ||
LAST_END_TIME_KEY, | ||
AccountAttributes, | ||
ArticleComments, | ||
ArticleCommentVotes, | ||
Articles, | ||
ArticleVotes, | ||
AttributeDefinitions, | ||
AuditLogs, | ||
BaseZendeskSupportStream, | ||
|
@@ -70,6 +74,13 @@ | |
"credentials": {"credentials": "api_token", "email": "[email protected]", "api_token": "api_token"}, | ||
} | ||
|
||
# raw old config | ||
TEST_OLD_CONFIG = { | ||
"auth_method": {"auth_method": "api_token", "email": "[email protected]", "api_token": "api_token"}, | ||
"subdomain": "sandbox", | ||
"start_date": "2021-06-01T00:00:00Z", | ||
} | ||
|
||
TEST_CONFIG_WITHOUT_START_DATE = { | ||
"subdomain": "sandbox", | ||
"credentials": {"credentials": "api_token", "email": "[email protected]", "api_token": "api_token"}, | ||
|
@@ -131,8 +142,12 @@ def test_default_start_date(): | |
|
||
@pytest.mark.parametrize( | ||
"config, expected", | ||
[(TEST_CONFIG, "aW50ZWdyYXRpb24tdGVzdEBhaXJieXRlLmlvL3Rva2VuOmFwaV90b2tlbg=="), (TEST_CONFIG_OAUTH, "test_access_token")], | ||
ids=["api_token", "oauth"], | ||
[ | ||
(TEST_CONFIG, "aW50ZWdyYXRpb24tdGVzdEBhaXJieXRlLmlvL3Rva2VuOmFwaV90b2tlbg=="), | ||
(TEST_CONFIG_OAUTH, "test_access_token"), | ||
(TEST_OLD_CONFIG, "aW50ZWdyYXRpb24tdGVzdEBhaXJieXRlLmlvL3Rva2VuOmFwaV90b2tlbg=="), | ||
], | ||
ids=["api_token", "oauth", "old_config"], | ||
) | ||
def test_get_authenticator(config, expected): | ||
# we expect base64 from creds input | ||
|
@@ -320,6 +335,12 @@ def test_streams(self, expected_stream_cls): | |
if expected_stream_cls in streams: | ||
assert isinstance(stream, expected_stream_cls) | ||
|
||
def test_ticket_forms_exception_stream(self): | ||
with patch.object(TicketForms, "read_records", return_value=[{}]) as mocked_records: | ||
mocked_records.side_effect = Exception("The error") | ||
streams = SourceZendeskSupport().streams(TEST_CONFIG) | ||
assert not any([isinstance(stream, TicketForms) for stream in streams]) | ||
|
||
@pytest.mark.parametrize( | ||
"stream_cls, expected", | ||
[ | ||
|
@@ -756,10 +777,12 @@ def test_next_page_token(self, requests_mock, stream_cls): | |
[ | ||
(Users, {"start_time": 1622505600}), | ||
(Tickets, {"start_time": 1622505600}), | ||
(Articles, {"sort_by": "updated_at", "sort_order": "asc", "start_time": 1622505600}), | ||
], | ||
ids=[ | ||
"Users", | ||
"Tickets", | ||
"Articles", | ||
], | ||
) | ||
def test_request_params(self, stream_cls, expected): | ||
|
@@ -787,6 +810,23 @@ def test_parse_response(self, requests_mock, stream_cls): | |
output = list(stream.parse_response(test_response)) | ||
assert expected == output | ||
|
||
@pytest.mark.parametrize( | ||
"stream_cls, stream_slice, expected_path", | ||
[ | ||
(ArticleVotes, {"parent": {"id": 1}}, "help_center/articles/1/votes"), | ||
(ArticleComments, {"parent": {"id": 1}}, "help_center/articles/1/comments"), | ||
(ArticleCommentVotes, {"parent": {"id": 1, "source_id": 1}}, "help_center/articles/1/comments/1/votes"), | ||
], | ||
ids=[ | ||
"ArticleVotes_path", | ||
"ArticleComments_path", | ||
"ArticleCommentVotes_path", | ||
], | ||
) | ||
def test_path(self, stream_cls, stream_slice, expected_path): | ||
stream = stream_cls(**STREAM_ARGS) | ||
assert stream.path(stream_slice=stream_slice) == expected_path | ||
|
||
|
||
class TestSourceZendeskSupportTicketEventsExportStream: | ||
@pytest.mark.parametrize( | ||
|
Oops, something went wrong.