-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[TDL-15661] Implement dev mode for 2.latest (#64)
* TDL-20058: Add missing integration tests. (#61) * Added missing assersions in tap-tester tests * updated tap-tester tests * added docstring for test case classes * updated test cases Co-authored-by: harshpatel4crest <[email protected]> * TDL-13906: Update README.md (#60) * updated readme file, init and added unittest * updated config.yml file * added logger for sync mode * formatted unitttests * TDL-20063: Add unit test cases (#59) * added unittest of sync.py * updated config.yml file * added unittest for unknown stream sync and updated sync code * updated unittests * formatted unittest * TDL-20061: Added missing fields (#58) * Added missing fields & add shared schema * Updated types * Updated types * Reverted datatype for some fields * Updated datatype for QtyOnHand Co-authored-by: harshpatel4crest <[email protected]> * TDL-20062: Add minor version in API requests (#57) * Added minor version in requests * Added unit tests * Removed workaround for some fields as minorversion is added * Fixed all field test * Updated code comment * resolved unittest failure Co-authored-by: harshpatel4crest <[email protected]> * TDL-20057: Add custom exception handling (#56) * added exception handling * added parameterized import in config.yml file * updated test case name * handled other 4XX error and updated test cases * added test case * updated test case * added pylint * updated formatting * formatted test case * TDL-20059: Implement currently_syncing (#55) * added currently syncing functionality * added interrupted sync tap-tester test * updated test case * Updated the tests method to use common test name to use token chaining * Updated the test method to use common test name to use token chaining * updated interrupted sync test * updated interrupted sync test * added docstring for test case name * updated comment indentation * updated tap-tester tests * updated interrupted sync test case * updated interrupted sync test case * formatted test case * resolve unittest failure Co-authored-by: RushT007 <[email protected]> * added new stream CustomerType (#62) * Implemented dev mode for tap-quickbooks * Make pylint happy * Reducing the instance attributes and updated the pylint disable with too-many-instance-attributes * added new test cases for dev mode * Fixing the review comments * (dev-mode) Removing the expires_at key and modifiying the logic accordingly. * Make pylint happy * update singer-python version * remove the extra test file * Remove the unit test for currently syncing as it is already getting tested in interrupt sync * pass the arguments while creating the QuickbooksClient * Reformat code * Update setup.py and changelog.md for dev mode support
- Loading branch information
1 parent
ee37570
commit 27230bf
Showing
8 changed files
with
105 additions
and
13 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
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,63 @@ | ||
import json | ||
import os | ||
import unittest | ||
from datetime import timedelta | ||
from unittest.mock import patch, MagicMock | ||
|
||
import singer | ||
from singer.utils import now, strftime | ||
from tap_quickbooks.client import QuickbooksClient | ||
|
||
LOGGER = singer.get_logger() | ||
|
||
|
||
class Test_ClientDevMode(unittest.TestCase): | ||
"""Test the dev mode functionality.""" | ||
|
||
def setUp(self): | ||
"""Creates a sample config for test execution""" | ||
# Data to be written | ||
self.mock_config = { | ||
"user_agent": "test_user_agent", | ||
"access_token": "sample_access_token", | ||
"refresh_token": "sample_refresh_token", | ||
"client_id": "sample_client_id", | ||
"client_secret": "sample_client_secret", | ||
"realm_id": "1234567890", | ||
"expires_at": strftime(now() + timedelta(hours=1)) | ||
} | ||
self.tmp_config_filename = "sample_quickbooks_config.json" | ||
|
||
# Serializing json | ||
json_object = json.dumps(self.mock_config, indent=4) | ||
# Writing to sample_quickbooks_config.json | ||
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_quickbooks.client.QuickbooksClient._write_config") | ||
@patch("requests_oauthlib.OAuth2Session.request", return_value=MagicMock(status_code=200)) | ||
def test_client_with_dev_mode(self, mock_request, mock_write_config): | ||
"""Checks the dev mode implementation and verifies write config functionality is | ||
not called""" | ||
QuickbooksClient(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.assertEquals(mock_write_config.call_count, 0) | ||
|
||
@patch("requests_oauthlib.OAuth2Session.request", return_value=MagicMock(status_code=200)) | ||
def test_client_dev_mode_missing_access_token(self, mock_request): | ||
"""Exception should be raised if missing access token""" | ||
|
||
del self.mock_config["access_token"] | ||
|
||
with self.assertRaises(Exception): | ||
QuickbooksClient(config_path=self.tmp_config_filename, | ||
config=self.mock_config, | ||
dev_mode=True) |
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