From f6e5ab7e5382920e20f3117630c57d8a67f54b93 Mon Sep 17 00:00:00 2001 From: Andy Lu Date: Tue, 8 Jul 2025 17:20:08 +0000 Subject: [PATCH 1/4] Bump versions --- setup.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index 50748a9..0341ce6 100644 --- a/setup.py +++ b/setup.py @@ -10,9 +10,9 @@ classifiers=['Programming Language :: Python :: 3 :: Only'], py_modules=['tap_square'], install_requires=[ - 'singer-python==5.10.0', + 'singer-python==5.13.2', 'squareup==28.0.0.20230608', - 'backoff==1.8.0', + 'backoff==1.10.0', 'methodtools==0.4.2', ], extras_require={ From 13b38726f52b8b2c4bb448bb25d239a2f40199a0 Mon Sep 17 00:00:00 2001 From: Andy Lu Date: Tue, 15 Jul 2025 16:37:31 +0000 Subject: [PATCH 2/4] Don't hammer the API --- tests/test_client.py | 30 ++++++++---------------------- 1 file changed, 8 insertions(+), 22 deletions(-) diff --git a/tests/test_client.py b/tests/test_client.py index 99cda93..dbbe9de 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -558,28 +558,14 @@ def get_object_matching_conditions(self, stream, object_id, start_date, keys_exi Poll Square for a specific set of key(s) that we know are not immediately returned. ex. A completed payment will have a processing_fee field added after the api call is already returned. """ - attempts = 0 - while attempts < 25: - LOGGER.info('get_object_matching_conditions: Calling %s API in retry loop [attemps: %s]', stream, attempts) - all_objects = self.get_all(stream, start_date) - found_object = [object for object in all_objects if object['id'] == object_id] - attempts += 1 - if not found_object: - LOGGER.warning("Stream %s Object with id %s not found, retrying", stream, object_id) - continue - - if not set(found_object[0].keys()).issuperset(keys_exist): - LOGGER.warning("Stream %s Object with id %s doesn't have enough keys, [object=%s][keys_exist=%s]", stream, object_id, found_object[0], keys_exist) - continue - - if all([found_object[0].get(key) == value for key, value in kwargs.items()]): - LOGGER.info('get_object_matching_conditions found %s object successfully: %s', stream, found_object) - return found_object - else: - LOGGER.warning("Stream %s Object with id %s doesn't have matching keys and values from the expectation, will poll again [expected key-values: kwargs=%s][found_object=%s]", stream, object_id, kwargs, found_object[0]) - - LOGGER.error("Polling Failed for stream %s object with id %s \n [expected key-values: kwargs=%s][found_object=%s]", stream, object_id, kwargs, found_object[0]) - raise RuntimeError() + all_objects = self.get_all(stream, start_date) + found_object = [object for object in all_objects if object['id'] == object_id] + if len(found_object) > 0 and all([found_object[0].get(key) == value for key, value in kwargs.items()]): + LOGGER.info('get_object_matching_conditions found %s object successfully: %s', stream, found_object) + return found_object + else: + msg = f'Object missing keys. {{ "stream": "{stream}", "id": "{object_id}", "expected-key-values": "{kwargs}", "object": "{found_object}"' + raise RuntimeError(msg) ########################################################################## ### CREATEs From 050edd4a90533262ea757d059bdf961fa5920ddc Mon Sep 17 00:00:00 2001 From: Andy Lu Date: Tue, 15 Jul 2025 16:37:44 +0000 Subject: [PATCH 3/4] Maybe get tests passing --- tests/test_bookmarks_cursor.py | 13 +++++++------ tests/test_pagination.py | 13 +++++++------ 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/tests/test_bookmarks_cursor.py b/tests/test_bookmarks_cursor.py index 8ef3bfd..6efac79 100644 --- a/tests/test_bookmarks_cursor.py +++ b/tests/test_bookmarks_cursor.py @@ -63,12 +63,13 @@ def bookmarks_test(self, testable_streams): # verify the expected test data exceeds API LIMIT for all testable streams for stream in testable_streams: - record_count = len(stream_to_expected_records_before_removing_first_page[stream]) - LOGGER.info('Verifying data is sufficient for stream {}. '.format(stream) + - "\tRecord Count: {}\tAPI Limit: {} ".format(record_count, self.API_LIMIT.get(stream))) - self.assertGreater(record_count, self.API_LIMIT.get(stream), - msg="Pagination not ensured.\n" + - "{} does not have sufficient data in expecatations.\n ".format(stream)) + with self.subTest(stream=stream): + record_count = len(stream_to_expected_records_before_removing_first_page[stream]) + LOGGER.info('Verifying data is sufficient for stream {}. '.format(stream) + + "\tRecord Count: {}\tAPI Limit: {} ".format(record_count, self.API_LIMIT.get(stream))) + self.assertGreater(record_count, self.API_LIMIT.get(stream), + msg="Pagination not ensured.\n" + + "{} does not have sufficient data in expecatations.\n ".format(stream)) stream_to_first_page_records = dict() stream_to_cursor = dict() diff --git a/tests/test_pagination.py b/tests/test_pagination.py index 75d8c44..37c2c17 100644 --- a/tests/test_pagination.py +++ b/tests/test_pagination.py @@ -83,12 +83,13 @@ def pagination_test(self): # verify the expected test data exceeds API LIMIT for all testable streams for stream in self.TESTABLE_STREAMS: - record_count = len(expected_records[stream]) - LOGGER.info('Verifying data is sufficient for stream {}. '.format(stream) + - "\tRecord Count: {}\tAPI Limit: {} ".format(record_count, self.API_LIMIT.get(stream))) - self.assertGreater(record_count, self.API_LIMIT.get(stream), - msg="Pagination not ensured.\n" + - "{} does not have sufficient data in expecatations.\n ".format(stream)) + with self.subTest(stream=stream): + record_count = len(expected_records[stream]) + LOGGER.info('Verifying data is sufficient for stream {}. '.format(stream) + + "\tRecord Count: {}\tAPI Limit: {} ".format(record_count, self.API_LIMIT.get(stream))) + self.assertGreater(record_count, self.API_LIMIT.get(stream), + msg="Pagination not ensured.\n" + + "{} does not have sufficient data in expecatations.\n ".format(stream)) # Create connection but do not use default start date conn_id = connections.ensure_connection(self, original_properties=False, payload_hook=self.preserve_access_token) From 4ba5d51f0162fd989276900b4e99cc2633e2676c Mon Sep 17 00:00:00 2001 From: Ben Allred Date: Tue, 15 Jul 2025 19:32:55 +0000 Subject: [PATCH 4/4] Bump tap version and update changelog --- CHANGELOG.md | 7 +++++++ setup.py | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 57c18a3..dec59e1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Changelog +## [v2.3.2](2025-07-15) + +[Full Changelog](https://github.com/singer-io/tap-square/compare/v2.3.1...v2.3.2) +* Bump dependency versions for twistlock compliance +* Update tests to fix circleci build +* [#125](https://github.com/singer-io/tap-square/pull/125) + ## [v2.3.1](2025-01-23) [Full Changelog](https://github.com/singer-io/tap-square/compare/v2.3.0...v2.3.1) diff --git a/setup.py b/setup.py index 0341ce6..324a2ad 100644 --- a/setup.py +++ b/setup.py @@ -3,7 +3,7 @@ from setuptools import setup setup(name='tap-square', - version='2.3.1', + version='2.3.2', description='Singer.io tap for extracting data from the Square API', author='Stitch', url='http://singer.io',