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

Tdl 23354 fix integration tests #115

Open
wants to merge 18 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,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==5.3.0.20200528'
pip install 'squareup==28.0.0.20230608'
run-test --tap=tap-square tests/test_discovery.py
- slack/status:
channel: 'stitch-tap-tester-tests'
Expand Down Expand Up @@ -126,7 +126,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==5.3.0.20200528'
pip install 'squareup==28.0.0.20230608'
run-test --tap=tap-square tests/test_sync_canary.py
- slack/status:
channel: 'stitch-tap-tester-tests'
Expand Down Expand Up @@ -155,7 +155,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==5.3.0.20200528'
pip install 'squareup==28.0.0.20230608'
run-test --tap=tap-square tests/test_default_start_date.py
- slack/status:
channel: 'stitch-tap-tester-tests'
Expand Down Expand Up @@ -185,7 +185,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==5.3.0.20200528'
pip install 'squareup==28.0.0.20230608'
run-test --tap=tap-square tests/test_automatic_fields.py
- run:
when: always
Expand All @@ -194,7 +194,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==5.3.0.20200528'
pip install 'squareup==28.0.0.20230608'
run-test --tap=tap-square tests/test_all_fields.py
- run:
when: always
Expand All @@ -203,7 +203,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==5.3.0.20200528'
pip install 'squareup==28.0.0.20230608'
run-test --tap=tap-square tests/test_bookmarks.py
- run:
when: always
Expand All @@ -212,7 +212,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==5.3.0.20200528'
pip install 'squareup==28.0.0.20230608'
run-test --tap=tap-square tests/test_bookmarks_static.py
- run:
when: always
Expand All @@ -221,7 +221,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==5.3.0.20200528'
pip install 'squareup==28.0.0.20230608'
run-test --tap=tap-square tests/test_start_date.py
- run:
when: always
Expand All @@ -230,7 +230,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==5.3.0.20200528'
pip install 'squareup==28.0.0.20230608'
run-test --tap=tap-square tests/test_pagination.py
- run:
when: always
Expand All @@ -239,7 +239,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==5.3.0.20200528'
pip install 'squareup==28.0.0.20230608'
run-test --tap=tap-square tests/test_bookmarks_cursor.py
- slack/status:
channel: 'stitch-tap-tester-tests'
Expand Down Expand Up @@ -331,4 +331,4 @@ workflows:
- non-parallizable-tests:
context:
- circleci-user
- tap-tester-user
- tap-tester-user
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ This tap:
* BankAccounts
* Refunds
* Payments
* Payouts
* ModifierLists
* Inventories
* Orders
* Roles
* Shifts
* CashDrawerShifts
* Settlements
* Customers

* Includes a schema for each resource reflecting most recent tested data retrieved using the api. See [the schema folder](https://github.com/singer-io/tap-square/tree/master/tap_square/schemas) for details.
Expand Down
58 changes: 28 additions & 30 deletions tap_square/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,33 +348,31 @@ def get_roles(self, bookmarked_cursor):
bookmarked_cursor,
)

def get_settlements(self, location_id, start_time, bookmarked_cursor):
url = 'https://connect.squareup.com/v1/{}/settlements'.format(location_id)

now = utils.now()
start_time_dt = utils.strptime_to_utc(start_time)
end_time_dt = now

# Parameter `begin_time` cannot be before 1 Jan 2013 00:00:00Z
# Doc: https://developer.squareup.com/reference/square/settlements-api/v1-list-settlements
if start_time_dt < utils.strptime_to_utc("2013-01-01T00:00:00Z"):
raise Exception("Start Date for Settlements stream cannot come before `2013-01-01T00:00:00Z`, current start_date: {}".format(start_time))

while start_time_dt < now:
params = {
'limit': 200,
'begin_time': utils.strftime(start_time_dt),
}
# If query range is over a year, shorten to a year
if now - start_time_dt > timedelta(weeks=52):
end_time_dt = start_time_dt + timedelta(weeks=52)
params['end_time'] = utils.strftime(end_time_dt)
yield from self._get_v1_objects(
url,
params,
'settlements',
bookmarked_cursor,
)
# Attempt again to sync til "now"
start_time_dt = end_time_dt
end_time_dt = now
def get_payouts(self, location_id, start_time, bookmarked_cursor):
if bookmarked_cursor:
cursor = bookmarked_cursor
else:
cursor = '__initial__' # initial value so while loop is always entered one time

end_time = utils.strftime(utils.now(), utils.DATETIME_PARSE)
while cursor:
if cursor == '__initial__':
# initial text was needed to go into the while loop, but api needs
# it to be a valid bookmarked cursor or None
cursor = bookmarked_cursor

with singer.http_request_timer('GET payouts details'):
result = self._retryable_v2_method(
lambda bdy: self._client.payouts.list_payouts(
location_id=location_id,
begin_time=start_time,
end_time=end_time,
cursor=cursor,
limit=100,
),
None,
)

yield (result.body.get('items', []), result.body.get('cursor'))

cursor = result.body.get('cursor')
2 changes: 1 addition & 1 deletion tap_square/discover.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def get_abs_path(path):
return os.path.join(os.path.dirname(os.path.realpath(__file__)), path)

# NB: These streams cannot be queried using Sandbox OAuth credentials
PRODUCTION_ONLY_STREAMS = {'roles', 'bank_accounts', 'settlements'}
PRODUCTION_ONLY_STREAMS = {'roles', 'bank_accounts', 'payouts'}

def get_schemas(sandbox):

Expand Down
152 changes: 152 additions & 0 deletions tap_square/schemas/payouts.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
{
"type": [
"null",
"object"
],
"properties": {
"id": {
"type": [
"null",
"string"
]
},
"status": {
"type": [
"null",
"string"
]
},
"location_id": {
"type": [
"null",
"string"
]
},
"created_at": {
"type": [
"null",
"string"
],
"format": "date-time"
},
"updated_at": {
"type": [
"null",
"string"
],
"format": "date-time"
},
"amount_money": {
"type": [
"null",
"object"
],
"properties": {
"amount": {
"type": [
"null",
"integer"
]
},
"currency": {
"type": [
"null",
"string"
]
}
}
},
"destination": {
"type": [
"null",
"object"
],
"properties": {
"type": {
"type": [
"null",
"string"
]
},
"id": {
"type": [
"null",
"string"
]
}
}
},
"version": {
"type": [
"null",
"integer"
]
},
"type": {
"type": [
"null",
"string"
]
},
"payout_fee": {
"type": [
"null",
"array"
],
"items": {
"type": [
"null",
"object"
],
"properties": {
"effective_at": {
"type": [
"null",
"string"
],
"format": "date-time"
},
"type": {
"type": [
"null",
"string"
]
},
"amount_money": {
"type": [
"null",
"object"
],
"properties": {
"amount": {
"type": [
"null",
"integer"
]
},
"currency": {
"type": [
"null",
"string"
]
}
}
}
}
}
},
"arrival_date": {
"type": [
"null",
"string"
],
"format": "date-time"
},
"end_to_end_id": {
"type": [
"null",
"string"
]
}
}
}
62 changes: 0 additions & 62 deletions tap_square/schemas/settlements.json

This file was deleted.

Loading