-
Notifications
You must be signed in to change notification settings - Fork 58
TDL-15774 : Update refresh tokens to chain (dev-mode) #104
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
Open
shantanu73
wants to merge
6
commits into
master
Choose a base branch
from
TDL-15774-dev-mode
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 3 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
e50fb09
Added code and unit tests for dev-mode
shantanu73 4b2284a
Changes:
shantanu73 9746741
Changes:
shantanu73 36861e8
Merge branch 'master' of github.com:singer-io/tap-jira into TDL-15774…
shantanu73 5387ce6
Changes:
shantanu73 be39816
Changes:
shantanu73 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,74 @@ | ||
| import json | ||
| import os | ||
| import unittest | ||
| from unittest.mock import patch, MagicMock | ||
|
|
||
| import singer | ||
|
|
||
| from tap_jira.http import Client | ||
|
|
||
|
|
||
| LOGGER = singer.get_logger() | ||
|
|
||
|
|
||
| class TestClientDevMode(unittest.TestCase): | ||
| """Test the dev mode functionality.""" | ||
|
|
||
| def setUp(self): | ||
| """Creates a sample config for test execution""" | ||
| # Data to be written | ||
| self.mock_config = { | ||
| "oauth_client_secret": "sample_client_secret", | ||
| "user_agent": "test_user_agent", | ||
| "oauth_client_id": "sample_client_id", | ||
| "access_token": "sample_access_token", | ||
| "cloud_id": "1234567890", | ||
| "refresh_token": "sample_refresh_token", | ||
| "start_date": "2017-12-04T19:19:32Z", | ||
| "request_timeout": 300, | ||
| "groups": "jira-administrators, site-admins, jira-software-users", | ||
| } | ||
|
|
||
| self.tmp_config_filename = "sample_jira_config.json" | ||
|
|
||
| # Serializing json | ||
| json_object = json.dumps(self.mock_config, indent=4) | ||
| # Writing to sample_quickbooks_config.json | ||
shantanu73 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| with open(self.tmp_config_filename, "w") as outfile: | ||
| outfile.write(json_object) | ||
|
|
||
| def tearDown(self): | ||
| """Deletes the sample config""" | ||
| if os.path.isfile(self.tmp_config_filename): | ||
| os.remove(self.tmp_config_filename) | ||
|
|
||
| @patch("tap_jira.http.Client.request", return_value=MagicMock(status_code=200)) | ||
| @patch("requests.Session.post", return_value=MagicMock(status_code=200)) | ||
| @patch("tap_jira.http.Client._write_config") | ||
| def test_client_with_dev_mode( | ||
| self, mock_write_config, mock_post_request, mock_request | ||
| ): | ||
| """Checks the dev mode implementation and verifies write config functionality is | ||
| not called""" | ||
| Client( | ||
| config_path=self.tmp_config_filename, config=self.mock_config, dev_mode=True | ||
| ) | ||
|
|
||
| # _write_config function should never be called as it will update the config | ||
| self.assertEqual(mock_write_config.call_count, 0) | ||
|
|
||
| @patch("tap_jira.http.Client.request", return_value=MagicMock(status_code=200)) | ||
| @patch("requests.Session.post", side_effect=Exception()) | ||
| def test_client_dev_mode_missing_access_token( | ||
| self, mock_post_request, mock_request | ||
| ): | ||
| """Exception should be raised if missing access token""" | ||
|
|
||
| del self.mock_config["access_token"] | ||
|
|
||
| with self.assertRaises(Exception): | ||
| Client( | ||
| config_path=self.tmp_config_filename, | ||
| config=self.mock_config, | ||
| dev_mode=True, | ||
| ) | ||
This file contains hidden or 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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.