-
Notifications
You must be signed in to change notification settings - Fork 30
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-20208 Add warning message for pro account plan. #49
Open
prijendev
wants to merge
6
commits into
TDL-20359-add-custom-exception-handling
Choose a base branch
from
TDL-20208-extremely-slow-data
base: TDL-20359-add-custom-exception-handling
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.
+55
−10
Open
Changes from 1 commit
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
c725481
Added warning message for pro account plan.
prijendev 81eefed
Merge branch 'TDL-20359-add-custom-exception-handling' into TDL-20208…
prijendev a93a5cf
Added assertion to verify logger message.
prijendev 180a499
Updated warning message.
prijendev 783cd1c
Merge branch 'TDL-20359-add-custom-exception-handling' into TDL-20208…
prijendev ef36eb5
Updated unit tests.
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
Next
Next commit
Added warning message for pro account plan.
commit c7254816cf782932647c8aee436bd43653ef808c
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,56 @@ | ||
import unittest | ||
from unittest import mock | ||
|
||
from tap_freshdesk import client | ||
from parameterized import parameterized | ||
|
||
|
||
@mock.patch("tap_freshdesk.client.FreshdeskClient.request") | ||
class TestAccessToken(unittest.TestCase): | ||
""" | ||
Test case to verify the `check_access_token` method. | ||
""" | ||
@parameterized.expand([ | ||
('free_account_with_invalid_token', client.FresdeskAuthenticationError, 'The Authorization header is either missing or incorrect.'), | ||
('free_account_with_invalid_domain', client.FresdeskNotFoundError, 'The request contains invalid ID/Freshdesk domain in the URL or an invalid URL itself.') | ||
]) | ||
def test_invalid_domain_or_token(self, mock_request, name, error, err_message): | ||
""" | ||
Verify that tap raise error for an invalid token or invalid domain name. | ||
""" | ||
config = {} | ||
mock_request.side_effect = error(err_message) | ||
_client = client.FreshdeskClient(config) | ||
with self.assertRaises(error) as e: | ||
_client.check_access_token() | ||
|
||
# Verify that an error message is expected | ||
self.assertEqual(str(e.exception), err_message) | ||
|
||
@mock.patch("tap_freshdesk.client.LOGGER.warning") | ||
def test_free_account(self, mock_request, mock_logger): | ||
""" | ||
Verify that tap provide a warning message to upgrade the current free account to the pro account. | ||
Because `satisfaction_ratings` and `time_entries` streams are accessible only for the pro account. | ||
""" | ||
config = {} | ||
mock_request.side_effect = client.FresdeskAccessDeniedError | ||
_client = client.FreshdeskClient(config) | ||
|
||
_client.check_access_token() | ||
|
||
# Verify that `LOGGER.warning` is called for 1 time. | ||
self.assertEqual(mock_logger.call_count, 1) | ||
dbshah1212 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
@mock.patch("tap_freshdesk.client.LOGGER.warning") | ||
def test_pro_account_plan(self, mock_logger, mock_request): | ||
""" | ||
Verify that tap does not raise any error or provide any warning message for the pro account plan. | ||
""" | ||
config = {} | ||
_client = client.FreshdeskClient(config) | ||
|
||
_client.check_access_token() | ||
|
||
# Verify that `LOGGER.warning` is not called. | ||
self.assertEqual(mock_logger.call_count, 0) |
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.
it is not the only reason so we should write this in might context like this might be the reason so check your account.
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.
Updated
warning
message.