Skip to content
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

Merged
merged 19 commits into from
Nov 30, 2022
Merged

Crest Work #63

merged 19 commits into from
Nov 30, 2022

Conversation

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 <[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]>
Copy link

@dsprayberry dsprayberry left a 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.

tap_quickbooks/__init__.py Show resolved Hide resolved
tap_quickbooks/sync.py Outdated Show resolved Hide resolved
tap_quickbooks/client.py Outdated Show resolved Hide resolved
tap_quickbooks/client.py Outdated Show resolved Hide resolved
tests/test_quickbooks_automatic_fields.py Show resolved Hide resolved
@RushiT0122
Copy link

@sgandhi1311 please fix the review comments.

tests/unittests/test_currently_syncing.py Outdated Show resolved Hide resolved
tests/unittests/test_currently_syncing.py Outdated Show resolved Hide resolved
tests/test_quickbooks_interrupted_sync.py Outdated Show resolved Hide resolved
tests/test_quickbooks_interrupted_sync.py Outdated Show resolved Hide resolved
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')

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

Copy link
Member

@sgandhi1311 sgandhi1311 Nov 9, 2022

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?

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

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

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

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

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

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
@@ -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")

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
Member

Choose a reason for hiding this comment

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

done

@@ -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

Choose a reason for hiding this comment

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

typo: reqion

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

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

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
Member

Choose a reason for hiding this comment

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

done

Copy link

@RushiT0122 RushiT0122 left a 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).


# Verify there is no duplicate metadata entries
self.assertEqual(len(actual_fields), len(set(actual_fields)), msg = "duplicates in the metadata entries retrieved")

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
Member

Choose a reason for hiding this comment

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

done

Copy link

@RushiT0122 RushiT0122 left a 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.

Copy link

@RushiT0122 RushiT0122 left a 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

@@ -29,6 +25,7 @@ def get_properties(self):


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

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

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

@sgandhi1311
Copy link
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