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 <harsh.patel4@crestdatasys.com>
* 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 <harsh.patel4@crestdatasys.com>
* 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 <harsh.patel4@crestdatasys.com>
* 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 <rtodkar@stitchdata-talend.com>
dsprayberry
left a comment
There was a problem hiding this comment.
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.
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.
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.
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.
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.
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.
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.
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): |
| @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): |
| @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): |
| 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.
Please remove this print() statement and replace it with tap-tester logger.
| 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 |
| return self.expected_check_streams() | ||
|
|
||
|
|
||
| def test_run(self): |
There was a problem hiding this comment.
Add the docstring of expectations here
| # 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.
This assertion deviates from the test objectives and should be covered in the pagination test, please remove it.
RushiT0122
left a comment
There was a problem hiding this comment.
Add docstrings in the tests to define the objectives of the test (wherever missing).
| actual_fields.append(md_entry['breadcrumb'][1]) | ||
|
|
||
| # 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.
Break the long line to keep consistency with above code.
RushiT0122
left a comment
There was a problem hiding this comment.
Requested changes in-line.
RushiT0122
left a comment
There was a problem hiding this comment.
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
|
|
||
|
|
||
| def test_run(self): | ||
| """Executing run_test with different page_size values for different streams""" |
There was a problem hiding this comment.
Mention the expectations in the docstring.
|
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