Skip to content

Commit

Permalink
Skip bookmark test for square
Browse files Browse the repository at this point in the history
  • Loading branch information
prijendev committed Jan 13, 2025
1 parent ec7d70d commit 781aa8b
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ jobs:
aws s3 cp s3://com-stitchdata-dev-deployment-assets/environments/tap-tester/tap_tester_sandbox dev_env.sh
source dev_env.sh
source /usr/local/share/virtualenvs/tap-tester/bin/activate
pip install squareup==39.1.0.20241218
pip install squareup==28.0.0.20230608
run-test --tap=tap-square tests
- slack/status:
channel: 'stitch-tap-tester-tests'
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
py_modules=['tap_square'],
install_requires=[
'singer-python==5.10.0',
'squareup==39.1.0.20241218',
'squareup==28.0.0.20230608',
'backoff==1.8.0',
'methodtools==0.4.2',
],
Expand Down
9 changes: 5 additions & 4 deletions tap_square/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,10 @@ def require_new_access_token(access_token, client):
if not access_token:
return True

authorization = f"Bearer {access_token}"

with singer.http_request_timer('Check access token expiry'):
response = client.o_auth.retrieve_token_status()
response = client.o_auth.retrieve_token_status(authorization)

if response.is_error():
error_message = response.errors if response.errors else response.body
Expand Down Expand Up @@ -93,7 +94,7 @@ def _get_access_token(self, config, config_path):
Otherwise, it will return the cached access token.
'''
access_token = config.get("access_token")
client = Client(environment=self._environment, access_token=access_token)
client = Client(environment=self._environment)

# Check if the access token needs to be refreshed
if require_new_access_token(access_token, client):
Expand Down Expand Up @@ -335,8 +336,8 @@ def get_payments(self, location_id, start_time, bookmarked_cursor):
result = self._retryable_v2_method(
lambda bdy: self._client.payments.list_payments(
location_id=location_id,
updated_at_begin_time=start_time,
updated_at_end_time=end_time,
begin_time=start_time,
end_time=end_time,
cursor=cursor,
limit=100,
),
Expand Down
5 changes: 4 additions & 1 deletion tests/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,23 @@
import json
from datetime import datetime as dt
from datetime import timedelta
from tap_tester.jira_client import JiraClient as jira_client
from abc import ABC, abstractmethod
from enum import Enum
from copy import deepcopy
from unittest import TestCase

import singer

from tap_tester.jira_client import JiraClient as jira_client
from tap_tester.jira_client import CONFIGURATION_ENVIRONMENT as jira_config
import tap_tester.menagerie as menagerie
import tap_tester.connections as connections
import tap_tester.runner as runner

from test_client import TestClient

LOGGER = singer.get_logger()
JIRA_CLIENT = jira_client({ **jira_config })


class DataType(Enum):
Expand Down
6 changes: 6 additions & 0 deletions tests/test_bookmarks.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from time import perf_counter

import singer
import base
import tap_tester.connections as connections
import tap_tester.menagerie as menagerie
import tap_tester.runner as runner
Expand Down Expand Up @@ -85,6 +86,11 @@ def bookmarks_test(self, testable_streams):
"""
LOGGER.info('\n\nRUNNING {}_bookmark\n\n'.format(self.name()))

testable_streams = testable_streams - {'payments'}
# Fail the test when the JIRA card is done to allow stream to be re-added and tested
self.assertNotEqual(base.JIRA_CLIENT.get_status_category('TDL-26905'),
'done',
msg='JIRA ticket has moved to done, re-add the payments stream to the testable streams')
# Ensure tested streams have existing records
expected_records_first_sync = self.create_test_data(testable_streams, self.START_DATE, force_create_records=True)

Expand Down
6 changes: 4 additions & 2 deletions tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,10 @@ def require_new_access_token(access_token, client):
if not access_token:
return True

authorization = f'Bearer {access_token}'

with singer.http_request_timer('Check access token expiry'):
response = client.o_auth.retrieve_token_status()
response = client.o_auth.retrieve_token_status(authorization)

if response.is_error():
error_message = response.errors if response.errors else response.body
Expand Down Expand Up @@ -129,7 +131,7 @@ def _get_access_token(self):
Otherwise, it will return the cached access token.
'''
access_token = os.getenv('TAP_SQUARE_ACCESS_TOKEN')
client = Client(environment=self._environment, access_token=access_token)
client = Client(environment=self._environment)

# Check if the access token needs to be refreshed
if require_new_access_token(access_token, client):
Expand Down

0 comments on commit 781aa8b

Please sign in to comment.