-
Notifications
You must be signed in to change notification settings - Fork 23
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
Crest Work #63
Crest Work #63
Conversation
* 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]>
* updated readme file, init and added unittest * updated config.yml file * added logger for sync mode * formatted unitttests
* added unittest of sync.py * updated config.yml file * added unittest for unknown stream sync and updated sync code * updated unittests * formatted unittest
* 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]>
* 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]>
* 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
* 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]>
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.
Note that I have not reviewed the last 12 files of this PR, but wanted to leave initial feedback so that those requested changes can be made.
@sgandhi1311 please fix the review comments. |
@mock.patch('time.sleep') | ||
@mock.patch('tap_quickbooks.client.QuickbooksClient._write_config') | ||
@mock.patch('requests_oauthlib.OAuth2Session.request') | ||
@mock.patch('tap_quickbooks.client.LOGGER.info') |
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.
Is this the correct order for the decorators? If so, is there a way to make this more clear? test_backoff_for_OAuth2Session has arguments in an order that doesn't quite match the above given that the parameterized expand would be test_name, test_data, expected_data but then sleep through logger are in reversed order from the function args
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.
Yes, the order is correct.
Using parametrized expand, multiple test cases will be created during execution. Function args are given in the same order as in the @parametrized.expand decorator. Ref - link
For @mock.patch decorators, it will follow the bottom-up approach. So the first function arg will relate to the lowermost patch decorator.
Any suggestions to make it more clear?
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.
I don't have any ideas tbh because a comment feels clunky. I guess I just haven't seen parameterized used with decorators or used that many decorators before 🤷
@mock.patch('tap_quickbooks.client.OAuth2Session.request') | ||
@mock.patch('tap_quickbooks.client.QuickbooksClient.get') | ||
class TestMinorVersion(unittest.TestCase): | ||
''' | ||
Tests to verify minor_version works as expected. | ||
''' | ||
|
||
def test_minor_version(self,mocked_get, mocked_request): |
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.
Is this the correct order for the decorators? If so, is there a way to make this more clear? each test function takes arguments in the opposite order of the decorators
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.
Yes, the order is correct.
For @mock.patch decorators, it will follow the bottom-up approach. So the first function arg will relate to the lowermost patch decorator.
Any suggestions to make it more clear?
@mock.patch('tap_quickbooks.client.QuickbooksClient.get') | ||
@mock.patch('singer.write_record') | ||
@mock.patch('singer.write_state') | ||
def test_sync_accounts(self, mock_write_state, mock_write_rcord, mock_get): |
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.
Is this the correct order for the decorators? If so, is there a way to make this more clear? each test function takes arguments in the opposite order of the decorators
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.
Please refer to the above response.
@mock.patch('tap_quickbooks.client.QuickbooksClient.get') | ||
@mock.patch('singer.write_record') | ||
@mock.patch('singer.write_state') | ||
@mock.patch('tap_quickbooks.client.QuickbooksClient.__init__', return_value=None) | ||
def test_sync_unknown_stream(self, mock_init, mock_write_state, mock_write_rcord, mock_get): |
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.
Same comment as above
@mock.patch('tap_quickbooks.client.QuickbooksClient.get') | ||
@mock.patch('singer.write_record') | ||
@mock.patch('singer.write_state') | ||
@mock.patch('tap_quickbooks.streams.ReportStream.parse_report_columns') | ||
@mock.patch('tap_quickbooks.streams.ReportStream.parse_report_rows') | ||
@mock.patch('tap_quickbooks.streams.ReportStream.day_wise_reports') | ||
@mock.patch('singer.utils.now') | ||
@mock.patch('tap_quickbooks.client.QuickbooksClient.__init__', return_value=None) | ||
def test_sync_report_stream(self, test_name, test_data, mock_init, mock_now, mock_day_wise_report, mock_report_rows, mock_report_columns, mock_write_state, mock_write_record, mock_get): |
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.
Same comment as above
@mock.patch('tap_quickbooks.client.QuickbooksClient.get') | ||
@mock.patch('singer.write_record') | ||
@mock.patch('singer.write_state') | ||
@mock.patch('tap_quickbooks.client.QuickbooksClient.__init__', return_value=None) | ||
def test_sync_deleted_stream(self, test_name, test_data_count, exp_write_state_count, exp_get_count, mock_init, mock_write_state, mock_write_record, mock_get): |
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.
Same comment as above
tests/test_quickbooks_discovery.py
Outdated
@@ -40,7 +39,7 @@ def test_run(self): | |||
self.assertTrue(all([re.fullmatch(r"[a-z_]+", name) for name in found_catalog_names]), | |||
msg="One or more streams don't follow standard naming") | |||
|
|||
diff = self.expected_check_streams().symmetric_difference(found_catalog_names) | |||
diff = expected_streams.symmetric_difference(found_catalog_names) | |||
self.assertEqual(len(diff), 0, msg="discovered schemas do not match: {}".format(diff)) | |||
print("discovered schemas are OK") |
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.
Please remove this print() statement and replace it with tap-tester logger.
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.
done
tests/test_quickbooks_all_fields.py
Outdated
@@ -2,6 +2,7 @@ | |||
from base import TestQuickbooksBase | |||
|
|||
class TestQuickbooksAllFields(TestQuickbooksBase): | |||
"""Test case to verify we are replicating all fields data from the Tap""" | |||
|
|||
# remove fields that are replicated when you have account for that specific reqion |
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.
typo: reqion
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.
fixed
""" | ||
return self.expected_check_streams() | ||
|
||
|
||
def test_run(self): |
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.
Add the docstring of expectations here
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.
added
# Verify the number or records exceeds the max_results (api limit) | ||
pagination_threshold = int(self.get_properties().get(page_size_key)) | ||
self.assertGreater(record_count, pagination_threshold, | ||
msg="Record count not large enough to gaurantee pagination.") | ||
msg="Record count not large enough to guarantee pagination.") |
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.
This assertion deviates from the test objectives and should be covered in the pagination test, please remove it.
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.
done
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.
Add docstrings in the tests to define the objectives of the test (wherever missing).
tests/test_quickbooks_discovery.py
Outdated
|
||
# Verify there is no duplicate metadata entries | ||
self.assertEqual(len(actual_fields), len(set(actual_fields)), msg = "duplicates in the metadata entries retrieved") |
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.
Break the long line to keep consistency with above code.
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.
done
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.
Requested changes in-line.
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.
test_quickbooks_interrupted_sync.py: refer test tap-yotpo interrupted sync test
test_quickbooks_sync_all.py: please re-review this test against other tests and see if we really need to test it, otherwise remove this test.
test
tests/test_quickbooks_pagination.py
Outdated
@@ -29,6 +25,7 @@ def get_properties(self): | |||
|
|||
|
|||
def test_run(self): | |||
"""Executing run_test with different page_size values for different streams""" |
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.
Mention the expectations in the docstring.
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.
done
I noticed init.py in integration tests, if not required we can remove that as well. |
removed |
Description of change
Manual QA steps
Risks
Rollback steps