Skip to content

Crest Work#63

Merged
sgandhi1311 merged 19 commits into
masterfrom
crest-master
Nov 30, 2022
Merged

Crest Work#63
sgandhi1311 merged 19 commits into
masterfrom
crest-master

Conversation

@hpatel41

@hpatel41 hpatel41 commented Sep 27, 2022

Copy link
Copy Markdown
Contributor

savan-chovatiya and others added 8 commits September 27, 2022 10:37
* 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 dsprayberry left a comment

Copy link
Copy Markdown
Contributor

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.

Comment thread tap_quickbooks/__init__.py
Comment thread tap_quickbooks/sync.py Outdated
Comment thread tap_quickbooks/client.py Outdated
Comment thread tap_quickbooks/client.py Outdated
Comment thread tests/test_quickbooks_automatic_fields.py
@RushiT0122

Copy link
Copy Markdown
Contributor

@sgandhi1311 please fix the review comments.

Comment thread tests/unittests/test_currently_syncing.py Outdated
Comment thread tests/unittests/test_currently_syncing.py Outdated
Comment thread tests/test_quickbooks_interrupted_sync.py Outdated
Comment thread tests/test_quickbooks_interrupted_sync.py Outdated
Comment on lines +31 to +34
@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')

Copy link
Copy Markdown
Contributor

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

@sgandhi1311 sgandhi1311 Nov 9, 2022

Copy link
Copy Markdown
Member

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?

Copy link
Copy Markdown
Contributor

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 🤷

Comment on lines +7 to +14
@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):

Copy link
Copy Markdown
Contributor

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

Copy link
Copy Markdown
Member

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?

Comment on lines +55 to +58
@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):

Copy link
Copy Markdown
Contributor

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

Copy link
Copy Markdown
Member

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.

Comment on lines +88 to +92
@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):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment as above

Comment on lines +110 to +118
@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):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment as above

Comment on lines +149 to +153
@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):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment as above

- removed currently syncing unit test case.
- In interrupt sync, made changes according to review comments
Comment thread tests/test_quickbooks_discovery.py Outdated
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")

Copy link
Copy Markdown
Contributor

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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment thread tests/test_quickbooks_all_fields.py Outdated
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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo: reqion

Copy link
Copy Markdown
Member

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):

Copy link
Copy Markdown
Contributor

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added

Comment on lines +110 to +113
# 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.")

Copy link
Copy Markdown
Contributor

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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@RushiT0122 RushiT0122 left a comment

Copy link
Copy Markdown
Contributor

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).

Comment thread tests/test_quickbooks_discovery.py Outdated
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")

Copy link
Copy Markdown
Contributor

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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@RushiT0122 RushiT0122 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requested changes in-line.

@RushiT0122 RushiT0122 left a comment

Copy link
Copy Markdown
Contributor

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

Comment thread tests/test_quickbooks_pagination.py Outdated


def test_run(self):
"""Executing run_test with different page_size values for different streams"""

Copy link
Copy Markdown
Contributor

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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@RushiT0122

Copy link
Copy Markdown
Contributor

I noticed init.py in integration tests, if not required we can remove that as well.

@sgandhi1311

Copy link
Copy Markdown
Member

I noticed init.py in integration tests, if not required we can remove that as well.

removed

@sgandhi1311 sgandhi1311 merged commit ee37570 into master Nov 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants