From 5ecb131d54f9bca9a121a692f8066b20c76cab8c Mon Sep 17 00:00:00 2001 From: prijendev Date: Tue, 16 Nov 2021 14:54:07 +0530 Subject: [PATCH 1/7] revert back check api changes --- tap_zendesk/discover.py | 14 ++- test/unittests/test_discovery_mode.py | 129 +++++++++++++++----------- 2 files changed, 87 insertions(+), 56 deletions(-) diff --git a/tap_zendesk/discover.py b/tap_zendesk/discover.py index 99f31b0..0709fec 100644 --- a/tap_zendesk/discover.py +++ b/tap_zendesk/discover.py @@ -58,10 +58,18 @@ def discover_streams(client, config): streams.append({'stream': stream.name, 'tap_stream_id': stream.name, 'schema': schema, 'metadata': stream.load_metadata()}) if error_list: + + total_stream = len(STREAMS.values()) # Total no od streams streams_name = ", ".join(error_list) - message = "HTTP-error-code: 403, Error: You are missing the following required scopes: read. "\ - "The account credentials supplied do not have read access for the following stream(s): {}".format(streams_name) - raise ZendeskForbiddenError(message) + message = "The account credentials supplied do not have read access for the following stream(s): {}."\ + "The data for the mentioned streams will not be collected if selected due to a lack of 'read' permission.".format(streams_name) + if len(error_list) == total_stream: + # If any one of stream does not have read permission then raise error. + raise ZendeskForbiddenError(message) + else: + # If atleast one stream have read permission then just print warning message for all streams + # which does not have read permission + LOGGER.warning(message) return streams diff --git a/test/unittests/test_discovery_mode.py b/test/unittests/test_discovery_mode.py index 0c7c266..66fdf80 100644 --- a/test/unittests/test_discovery_mode.py +++ b/test/unittests/test_discovery_mode.py @@ -26,6 +26,7 @@ class TestDiscovery(unittest.TestCase): ''' Test that we can call api for each stream in discovey mode and handle forbidden error. ''' + @patch("tap_zendesk.discover.LOGGER.warning") @patch('tap_zendesk.streams.Organizations.check_access',side_effect=zenpy.lib.exception.APIException(ACCSESS_TOKEN_ERROR)) @patch('tap_zendesk.streams.Users.check_access',side_effect=zenpy.lib.exception.APIException(ACCSESS_TOKEN_ERROR)) @patch('tap_zendesk.streams.TicketForms.check_access',side_effect=zenpy.lib.exception.APIException(ACCSESS_TOKEN_ERROR)) @@ -47,32 +48,25 @@ class TestDiscovery(unittest.TestCase): mocked_get(status_code=403, json={"key1": "val1"}), # Response of the 9th get request call mocked_get(status_code=403, json={"key1": "val1"}) # Response of the 10th get request call ]) - def test_discovery_handles_403__raise_tap_zendesk_forbidden_error(self, mock_get, mock_resolve_schema_references, - mock_load_metadata, mock_load_schema,mock_load_shared_schema_refs, mocked_sla_policies, - mocked_ticket_forms, mock_users, mock_organizations): + def test_discovery_handles_403__raise_tap_zendesk_forbidden_error(self, mock_get, mock_resolve_schema_references, + mock_load_metadata, mock_load_schema,mock_load_shared_schema_refs, mocked_sla_policies, + mocked_ticket_forms, mock_users, mock_organizations, mock_logger): ''' - Test that we handle forbidden error for child streams. discover_streams calls check_access for each stream to - check the read perission. discover_streams call many other methods including load_shared_schema_refs, load_metadata, - load_schema, resolve_schema_references also which we mock to test forbidden error. We mock check_access method of + Test that we handle forbidden error for child streams. discover_streams calls check_access for each stream to + check the read perission. discover_streams call many other methods including load_shared_schema_refs, load_metadata, + load_schema, resolve_schema_references also which we mock to test forbidden error. We mock check_access method of some of stream method which call request of zenpy module and also mock get method of requests module with 200, 403 error. ''' - try: - responses = discover.discover_streams('dummy_client', {'subdomain': 'arp', 'access_token': 'dummy_token', 'start_date':START_DATE}) - except tap_zendesk.http.ZendeskForbiddenError as e: - expected_error_message = "HTTP-error-code: 403, Error: You are missing the following required scopes: read. "\ - "The account credentials supplied do not have read access for the following stream(s): groups, users, "\ - "organizations, ticket_audits, ticket_comments, ticket_fields, ticket_forms, group_memberships, macros, "\ - "satisfaction_ratings, tags, ticket_metrics" - - # Verifying the message formed for the custom exception - self.assertEqual(str(e), expected_error_message) + discover.discover_streams('dummy_client', {'subdomain': 'arp', 'access_token': 'dummy_token', 'start_date':START_DATE}) - expected_call_count = 10 - actual_call_count = mock_get.call_count - self.assertEqual(expected_call_count, actual_call_count) + # Verifying the logger message + mock_logger.assert_called_with("The account credentials supplied do not have read access for the following "\ + "stream(s): groups, users, organizations, ticket_audits, ticket_comments, ticket_fields, ticket_forms, "\ + "group_memberships, macros, satisfaction_ratings, tags, ticket_metrics.The data for the mentioned streams "\ + "will not be collected if selected due to a lack of 'read' permission.") - + @patch("tap_zendesk.discover.LOGGER.warning") @patch('tap_zendesk.streams.Organizations.check_access',side_effect=zenpy.lib.exception.APIException(ACCSESS_TOKEN_ERROR)) @patch('tap_zendesk.streams.Users.check_access',side_effect=zenpy.lib.exception.APIException(ACCSESS_TOKEN_ERROR)) @patch('tap_zendesk.streams.TicketForms.check_access',side_effect=zenpy.lib.exception.APIException(ACCSESS_TOKEN_ERROR)) @@ -94,31 +88,25 @@ def test_discovery_handles_403__raise_tap_zendesk_forbidden_error(self, mock_get mocked_get(status_code=403, json={"key1": "val1"}), # Response of the 9th get request call mocked_get(status_code=403, json={"key1": "val1"}) # Response of the 10th get request call ]) - def test_discovery_handles_403_raise_zenpy_forbidden_error_for_access_token(self, mock_get, mock_resolve_schema_references, mock_load_metadata, - mock_load_schema,mock_load_shared_schema_refs, mocked_sla_policies, mocked_ticket_forms, - mock_users, mock_organizations): + def test_discovery_handles_403_raise_zenpy_forbidden_error_for_access_token(self, mock_get, mock_resolve_schema_references, mock_load_metadata, + mock_load_schema,mock_load_shared_schema_refs, mocked_sla_policies, mocked_ticket_forms, + mock_users, mock_organizations, mock_logger): ''' Test that we handle forbidden error received from last failed request which we called from zenpy module and - raised zenpy.lib.exception.APIException. discover_streams calls check_access for each stream to check the - read perission. discover_streams call many other methods including load_shared_schema_refs, load_metadata, - load_schema, resolve_schema_references also which we mock to test forbidden error. We mock check_access method of + log proper warning message. discover_streams calls check_access for each stream to check the + read perission. discover_streams call many other methods including load_shared_schema_refs, load_metadata, + load_schema, resolve_schema_references also which we mock to test forbidden error. We mock check_access method of some of stream method which call request of zenpy module and also mock get method of requests module with 200, 403 error. ''' - try: - responses = discover.discover_streams('dummy_client', {'subdomain': 'arp', 'access_token': 'dummy_token', 'start_date':START_DATE}) - except tap_zendesk.http.ZendeskForbiddenError as e: - expected_error_message = "HTTP-error-code: 403, Error: You are missing the following required scopes: read. "\ - "The account credentials supplied do not have read access for the following stream(s): groups, users, "\ - "organizations, ticket_audits, ticket_comments, ticket_fields, ticket_forms, group_memberships, macros, "\ - "satisfaction_ratings, tags, ticket_metrics, sla_policies" - - self.assertEqual(str(e), expected_error_message) - - expected_call_count = 10 - actual_call_count = mock_get.call_count - self.assertEqual(expected_call_count, actual_call_count) + discover.discover_streams('dummy_client', {'subdomain': 'arp', 'access_token': 'dummy_token', 'start_date':START_DATE}) + # Verifying the logger message + mock_logger.assert_called_with("The account credentials supplied do not have read access for the following stream(s): "\ + "groups, users, organizations, ticket_audits, ticket_comments, ticket_fields, ticket_forms, group_memberships, "\ + "macros, satisfaction_ratings, tags, ticket_metrics, sla_policies.The data for the mentioned streams will not be "\ + "collected if selected due to a lack of 'read' permission.") + @patch("tap_zendesk.discover.LOGGER.warning") @patch('tap_zendesk.streams.Organizations.check_access',side_effect=zenpy.lib.exception.APIException(API_TOKEN_ERROR)) @patch('tap_zendesk.streams.Users.check_access',side_effect=zenpy.lib.exception.APIException(API_TOKEN_ERROR)) @patch('tap_zendesk.streams.TicketForms.check_access',side_effect=zenpy.lib.exception.APIException(API_TOKEN_ERROR)) @@ -142,27 +130,20 @@ def test_discovery_handles_403_raise_zenpy_forbidden_error_for_access_token(self ]) def test_discovery_handles_403_raise_zenpy_forbidden_error_for_api_token(self, mock_get, mock_resolve_schema_references, mock_load_metadata, mock_load_schema,mock_load_shared_schema_refs, mocked_sla_policies, - mocked_ticket_forms, mock_users, mock_organizations): + mocked_ticket_forms, mock_users, mock_organizations, mock_logger): ''' Test that we handle forbidden error received from last failed request which we called from zenpy module and - raised zenpy.lib.exception.APIException. discover_streams calls check_access for each stream to check the + log proper warning message. discover_streams calls check_access for each stream to check the read perission. discover_streams call many other methods including load_shared_schema_refs, load_metadata, load_schema, resolve_schema_references also which we mock to test forbidden error. We mock check_access method of some of stream method which call request of zenpy module and also mock get method of requests module with 200, 403 error. ''' - try: - responses = discover.discover_streams('dummy_client', {'subdomain': 'arp', 'access_token': 'dummy_token', 'start_date':START_DATE}) - except tap_zendesk.http.ZendeskForbiddenError as e: - expected_error_message = "HTTP-error-code: 403, Error: You are missing the following required scopes: read. "\ - "The account credentials supplied do not have read access for the following stream(s): tickets, groups, users, "\ - "organizations, ticket_fields, ticket_forms, group_memberships, macros, satisfaction_ratings, tags" - - self.assertEqual(str(e), expected_error_message) - expected_call_count = 10 - actual_call_count = mock_get.call_count - self.assertEqual(expected_call_count, actual_call_count) - + responses = discover.discover_streams('dummy_client', {'subdomain': 'arp', 'access_token': 'dummy_token', 'start_date':START_DATE}) + # Verifying the logger message + mock_logger.assert_called_with("The account credentials supplied do not have read access for the following stream(s): "\ + "tickets, groups, users, organizations, ticket_fields, ticket_forms, group_memberships, macros, satisfaction_ratings, "\ + "tags.The data for the mentioned streams will not be collected if selected due to a lack of 'read' permission.") @patch('tap_zendesk.streams.Organizations.check_access',side_effect=zenpy.lib.exception.APIException(ACCSESS_TOKEN_ERROR)) @patch('tap_zendesk.streams.Users.check_access',side_effect=zenpy.lib.exception.APIException(ACCSESS_TOKEN_ERROR)) @@ -274,3 +255,45 @@ def test_discovery_handles_200_response(self, mock_get, mock_resolve_schema_refe expected_call_count = 10 actual_call_count = mock_get.call_count self.assertEqual(expected_call_count, actual_call_count) + + @patch("tap_zendesk.discover.LOGGER.warning") + @patch('tap_zendesk.streams.Organizations.check_access',side_effect=zenpy.lib.exception.APIException(API_TOKEN_ERROR)) + @patch('tap_zendesk.streams.Users.check_access',side_effect=zenpy.lib.exception.APIException(API_TOKEN_ERROR)) + @patch('tap_zendesk.streams.TicketForms.check_access',side_effect=zenpy.lib.exception.APIException(API_TOKEN_ERROR)) + @patch('tap_zendesk.streams.SLAPolicies.check_access',side_effect=zenpy.lib.exception.APIException(API_TOKEN_ERROR)) + @patch('tap_zendesk.discover.load_shared_schema_refs', return_value={}) + @patch('tap_zendesk.streams.Stream.load_metadata', return_value={}) + @patch('tap_zendesk.streams.Stream.load_schema', return_value={}) + @patch('singer.resolve_schema_references', return_value={}) + @patch('requests.get', + side_effect=[ + mocked_get(status_code=403, json={"key1": "val1"}), # Response of the 1st get request call + mocked_get(status_code=403, json={"key1": "val1"}), # Response of the 2nd get request call + mocked_get(status_code=403, json={"key1": "val1"}), # Response of the 3rd get request call + mocked_get(status_code=403, json={"key1": "val1"}), # Response of the 4th get request call + mocked_get(status_code=403, json={"key1": "val1"}), # Response of the 5th get request call + mocked_get(status_code=403, json={"key1": "val1"}), # Response of the 6th get request call + mocked_get(status_code=403, json={"key1": "val1"}), # Response of the 7th get request call + mocked_get(status_code=403, json={"key1": "val1"}), # Response of the 8th get request call + mocked_get(status_code=403, json={"key1": "val1"}), # Response of the 9th get request call + mocked_get(status_code=403, json={"key1": "val1"}) # Response of the 10th get request call + ]) + def test_discovery_handles_403_for_all_streams_api_token(self, mock_get, mock_resolve_schema_references, + mock_load_metadata, mock_load_schema,mock_load_shared_schema_refs, mocked_sla_policies, + mocked_ticket_forms, mock_users, mock_organizations, mock_logger): + ''' + Test that we handle forbidden error received from all streams and raise the ZendeskForbiddenError + with proper error message. discover_streams calls check_access for each stream to check the + read perission. discover_streams call many other methods including load_shared_schema_refs, load_metadata, + load_schema, resolve_schema_references also which we mock to test forbidden error. We mock check_access method of + some of stream method which call request of zenpy module and also mock get method of requests module with 200, 403 error. + ''' + try: + responses = discover.discover_streams('dummy_client', {'subdomain': 'arp', 'access_token': 'dummy_token', 'start_date':START_DATE}) + except http.ZendeskForbiddenError as e: + expected_message = "The account credentials supplied do not have read access for the following stream(s): "\ + "tickets, groups, users, organizations, ticket_audits, ticket_comments, ticket_fields, ticket_forms, "\ + "group_memberships, macros, satisfaction_ratings, tags, ticket_metrics, sla_policies.The data for the "\ + "mentioned streams will not be collected if selected due to a lack of 'read' permission." + # Verifying the message formed for the custom exception + self.assertEqual(str(e), expected_message) From 37b922ffc8a16176fe54b2b0c5da4c4f1f98c575 Mon Sep 17 00:00:00 2001 From: prijendev Date: Tue, 16 Nov 2021 15:00:16 +0530 Subject: [PATCH 2/7] resolvedd pylint error --- tap_zendesk/discover.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tap_zendesk/discover.py b/tap_zendesk/discover.py index 0709fec..5516ed9 100644 --- a/tap_zendesk/discover.py +++ b/tap_zendesk/discover.py @@ -59,17 +59,17 @@ def discover_streams(client, config): if error_list: - total_stream = len(STREAMS.values()) # Total no od streams + total_stream = len(STREAMS.values()) # Total no of streams streams_name = ", ".join(error_list) message = "The account credentials supplied do not have read access for the following stream(s): {}."\ "The data for the mentioned streams will not be collected if selected due to a lack of 'read' permission.".format(streams_name) - if len(error_list) == total_stream: - # If any one of stream does not have read permission then raise error. - raise ZendeskForbiddenError(message) - else: + if len(error_list) != total_stream: # If atleast one stream have read permission then just print warning message for all streams # which does not have read permission LOGGER.warning(message) + else: + # If any one of stream does not have read permission then raise error. + raise ZendeskForbiddenError(message) return streams From 12b448f5a70e3efbb360776e35568ef5f83fe5c6 Mon Sep 17 00:00:00 2001 From: prijendev Date: Tue, 16 Nov 2021 15:06:07 +0530 Subject: [PATCH 3/7] updated unittest cases --- test/unittests/test_discovery_mode.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/test/unittests/test_discovery_mode.py b/test/unittests/test_discovery_mode.py index 66fdf80..f1b355b 100644 --- a/test/unittests/test_discovery_mode.py +++ b/test/unittests/test_discovery_mode.py @@ -59,6 +59,9 @@ def test_discovery_handles_403__raise_tap_zendesk_forbidden_error(self, mock_get ''' discover.discover_streams('dummy_client', {'subdomain': 'arp', 'access_token': 'dummy_token', 'start_date':START_DATE}) + expected_call_count = 10 + actual_call_count = mock_get.call_count + self.assertEqual(expected_call_count, actual_call_count) # Verifying the logger message mock_logger.assert_called_with("The account credentials supplied do not have read access for the following "\ @@ -100,6 +103,10 @@ def test_discovery_handles_403_raise_zenpy_forbidden_error_for_access_token(self ''' discover.discover_streams('dummy_client', {'subdomain': 'arp', 'access_token': 'dummy_token', 'start_date':START_DATE}) + expected_call_count = 10 + actual_call_count = mock_get.call_count + self.assertEqual(expected_call_count, actual_call_count) + # Verifying the logger message mock_logger.assert_called_with("The account credentials supplied do not have read access for the following stream(s): "\ "groups, users, organizations, ticket_audits, ticket_comments, ticket_fields, ticket_forms, group_memberships, "\ @@ -140,6 +147,10 @@ def test_discovery_handles_403_raise_zenpy_forbidden_error_for_api_token(self, m ''' responses = discover.discover_streams('dummy_client', {'subdomain': 'arp', 'access_token': 'dummy_token', 'start_date':START_DATE}) + expected_call_count = 10 + actual_call_count = mock_get.call_count + self.assertEqual(expected_call_count, actual_call_count) + # Verifying the logger message mock_logger.assert_called_with("The account credentials supplied do not have read access for the following stream(s): "\ "tickets, groups, users, organizations, ticket_fields, ticket_forms, group_memberships, macros, satisfaction_ratings, "\ From cb1051de25ddc5e89ba46cf5ee550ca6eb52f0e7 Mon Sep 17 00:00:00 2001 From: prijendev Date: Tue, 16 Nov 2021 17:57:50 +0530 Subject: [PATCH 4/7] Updated error message --- tap_zendesk/discover.py | 8 ++++--- test/unittests/test_discovery_mode.py | 31 +++++++++++++-------------- 2 files changed, 20 insertions(+), 19 deletions(-) diff --git a/tap_zendesk/discover.py b/tap_zendesk/discover.py index 5516ed9..2f081f6 100644 --- a/tap_zendesk/discover.py +++ b/tap_zendesk/discover.py @@ -61,14 +61,16 @@ def discover_streams(client, config): total_stream = len(STREAMS.values()) # Total no of streams streams_name = ", ".join(error_list) - message = "The account credentials supplied do not have read access for the following stream(s): {}."\ - "The data for the mentioned streams will not be collected if selected due to a lack of 'read' permission.".format(streams_name) if len(error_list) != total_stream: + message = "The account credentials supplied do not have 'read' access to the following stream(s): {}. "\ + "The data for these streams would not be collected due to lack of required permission.".format(streams_name) # If atleast one stream have read permission then just print warning message for all streams # which does not have read permission LOGGER.warning(message) else: - # If any one of stream does not have read permission then raise error. + message = "HTTP-error-code: 403, Error: You are missing the following required scopes: read. "\ + "The account credentials supplied do not have read access for the following stream(s): {}".format(streams_name) + # If none of the streams are having the 'read' access, then the code will raise an error raise ZendeskForbiddenError(message) diff --git a/test/unittests/test_discovery_mode.py b/test/unittests/test_discovery_mode.py index f1b355b..4fbedb5 100644 --- a/test/unittests/test_discovery_mode.py +++ b/test/unittests/test_discovery_mode.py @@ -64,10 +64,10 @@ def test_discovery_handles_403__raise_tap_zendesk_forbidden_error(self, mock_get self.assertEqual(expected_call_count, actual_call_count) # Verifying the logger message - mock_logger.assert_called_with("The account credentials supplied do not have read access for the following "\ - "stream(s): groups, users, organizations, ticket_audits, ticket_comments, ticket_fields, ticket_forms, "\ - "group_memberships, macros, satisfaction_ratings, tags, ticket_metrics.The data for the mentioned streams "\ - "will not be collected if selected due to a lack of 'read' permission.") + mock_logger.assert_called_with("The account credentials supplied do not have 'read' access to the following stream(s): "\ + "groups, users, organizations, ticket_audits, ticket_comments, ticket_fields, ticket_forms, group_memberships, macros, "\ + "satisfaction_ratings, tags, ticket_metrics. The data for these streams would not be collected due to lack of required "\ + "permission.") @patch("tap_zendesk.discover.LOGGER.warning") @patch('tap_zendesk.streams.Organizations.check_access',side_effect=zenpy.lib.exception.APIException(ACCSESS_TOKEN_ERROR)) @@ -106,12 +106,12 @@ def test_discovery_handles_403_raise_zenpy_forbidden_error_for_access_token(self expected_call_count = 10 actual_call_count = mock_get.call_count self.assertEqual(expected_call_count, actual_call_count) - + # Verifying the logger message - mock_logger.assert_called_with("The account credentials supplied do not have read access for the following stream(s): "\ - "groups, users, organizations, ticket_audits, ticket_comments, ticket_fields, ticket_forms, group_memberships, "\ - "macros, satisfaction_ratings, tags, ticket_metrics, sla_policies.The data for the mentioned streams will not be "\ - "collected if selected due to a lack of 'read' permission.") + mock_logger.assert_called_with("The account credentials supplied do not have 'read' access to the following stream(s): "\ + "groups, users, organizations, ticket_audits, ticket_comments, ticket_fields, ticket_forms, group_memberships, macros, "\ + "satisfaction_ratings, tags, ticket_metrics, sla_policies. The data for these streams would not be collected due to "\ + "lack of required permission.") @patch("tap_zendesk.discover.LOGGER.warning") @patch('tap_zendesk.streams.Organizations.check_access',side_effect=zenpy.lib.exception.APIException(API_TOKEN_ERROR)) @@ -152,9 +152,9 @@ def test_discovery_handles_403_raise_zenpy_forbidden_error_for_api_token(self, m self.assertEqual(expected_call_count, actual_call_count) # Verifying the logger message - mock_logger.assert_called_with("The account credentials supplied do not have read access for the following stream(s): "\ + mock_logger.assert_called_with("The account credentials supplied do not have 'read' access to the following stream(s): "\ "tickets, groups, users, organizations, ticket_fields, ticket_forms, group_memberships, macros, satisfaction_ratings, "\ - "tags.The data for the mentioned streams will not be collected if selected due to a lack of 'read' permission.") + "tags. The data for these streams would not be collected due to lack of required permission.") @patch('tap_zendesk.streams.Organizations.check_access',side_effect=zenpy.lib.exception.APIException(ACCSESS_TOKEN_ERROR)) @patch('tap_zendesk.streams.Users.check_access',side_effect=zenpy.lib.exception.APIException(ACCSESS_TOKEN_ERROR)) @@ -302,9 +302,8 @@ def test_discovery_handles_403_for_all_streams_api_token(self, mock_get, mock_re try: responses = discover.discover_streams('dummy_client', {'subdomain': 'arp', 'access_token': 'dummy_token', 'start_date':START_DATE}) except http.ZendeskForbiddenError as e: - expected_message = "The account credentials supplied do not have read access for the following stream(s): "\ - "tickets, groups, users, organizations, ticket_audits, ticket_comments, ticket_fields, ticket_forms, "\ - "group_memberships, macros, satisfaction_ratings, tags, ticket_metrics, sla_policies.The data for the "\ - "mentioned streams will not be collected if selected due to a lack of 'read' permission." - # Verifying the message formed for the custom exception + expected_message = "HTTP-error-code: 403, Error: You are missing the following required scopes: read. The account credentials "\ + "supplied do not have read access for the following stream(s): tickets, groups, users, organizations, ticket_audits, "\ + "ticket_comments, ticket_fields, ticket_forms, group_memberships, macros, satisfaction_ratings, tags, ticket_metrics, sla_policies" + # # Verifying the message formed for the custom exception self.assertEqual(str(e), expected_message) From 7cf598b226a8d8b43990b40793f7b4cc06f33687 Mon Sep 17 00:00:00 2001 From: prijendev Date: Tue, 16 Nov 2021 18:29:09 +0530 Subject: [PATCH 5/7] updated error message --- tap_zendesk/discover.py | 4 ++-- test/unittests/test_discovery_mode.py | 5 ++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/tap_zendesk/discover.py b/tap_zendesk/discover.py index 2f081f6..1384276 100644 --- a/tap_zendesk/discover.py +++ b/tap_zendesk/discover.py @@ -68,8 +68,8 @@ def discover_streams(client, config): # which does not have read permission LOGGER.warning(message) else: - message = "HTTP-error-code: 403, Error: You are missing the following required scopes: read. "\ - "The account credentials supplied do not have read access for the following stream(s): {}".format(streams_name) + message ="HTTP-error-code: 403, Error: The account credentials supplied do not have 'read' access to any "\ + "of streams supported by the tap. Data collection cannot be initiated due to lack of permissions." # If none of the streams are having the 'read' access, then the code will raise an error raise ZendeskForbiddenError(message) diff --git a/test/unittests/test_discovery_mode.py b/test/unittests/test_discovery_mode.py index 4fbedb5..952d228 100644 --- a/test/unittests/test_discovery_mode.py +++ b/test/unittests/test_discovery_mode.py @@ -302,8 +302,7 @@ def test_discovery_handles_403_for_all_streams_api_token(self, mock_get, mock_re try: responses = discover.discover_streams('dummy_client', {'subdomain': 'arp', 'access_token': 'dummy_token', 'start_date':START_DATE}) except http.ZendeskForbiddenError as e: - expected_message = "HTTP-error-code: 403, Error: You are missing the following required scopes: read. The account credentials "\ - "supplied do not have read access for the following stream(s): tickets, groups, users, organizations, ticket_audits, "\ - "ticket_comments, ticket_fields, ticket_forms, group_memberships, macros, satisfaction_ratings, tags, ticket_metrics, sla_policies" + expected_message = "HTTP-error-code: 403, Error: The account credentials supplied do not have 'read' access to any "\ + "of streams supported by the tap. Data collection cannot be initiated due to lack of permissions." # # Verifying the message formed for the custom exception self.assertEqual(str(e), expected_message) From 010f7c938461f7aa93a9d298c1d36e7d181d54d7 Mon Sep 17 00:00:00 2001 From: KrishnanG Date: Tue, 16 Nov 2021 17:21:51 +0000 Subject: [PATCH 6/7] Added timeout for circleci --- .circleci/config.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index 7430186..cb0d5fb 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -29,6 +29,7 @@ jobs: path: htmlcov - run: name: 'Integration Tests' + no_output_timeout: 30m command: | aws s3 cp s3://com-stitchdata-dev-deployment-assets/environments/tap-tester/tap_tester_sandbox dev_env.sh source dev_env.sh From 2f1803d2ac5356fe1927e8668e513d3f579cfaa4 Mon Sep 17 00:00:00 2001 From: KrishnanG Date: Wed, 17 Nov 2021 03:15:19 +0000 Subject: [PATCH 7/7] Increased the timeout to 200minutes --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index cb0d5fb..3ca353e 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -29,7 +29,7 @@ jobs: path: htmlcov - run: name: 'Integration Tests' - no_output_timeout: 30m + no_output_timeout: 200m command: | aws s3 cp s3://com-stitchdata-dev-deployment-assets/environments/tap-tester/tap_tester_sandbox dev_env.sh source dev_env.sh