Skip to content

Commit

Permalink
source-braintree-native: redact capture snapshot fields for subscript…
Browse files Browse the repository at this point in the history
…ions

Every month, some of the fields in the capture snapshot for the
`subscriptions` stream will update as the billing cycle moves to the
next month. The fields that change have been redacted to make the
capture snapshot test more robust.
  • Loading branch information
Alex-Bair committed Jan 2, 2025
1 parent e855438 commit 38ecf7b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -564,10 +564,10 @@
"add_ons": [],
"balance": "0.00",
"billing_day_of_month": 26,
"billing_period_end_date": "2024-12-25",
"billing_period_start_date": "2024-11-26",
"billing_period_end_date": "redacted",
"billing_period_start_date": "redacted",
"created_at": "2024-11-26T16:29:00Z",
"current_billing_cycle": 1,
"current_billing_cycle": 0,
"days_past_due": null,
"description": null,
"descriptor": {
Expand All @@ -582,10 +582,10 @@
"merchant_account_id": "estuary",
"never_expires": true,
"next_bill_amount": "11.00",
"next_billing_date": "2024-12-26",
"next_billing_date": "redacted",
"next_billing_period_amount": "11.00",
"number_of_billing_cycles": null,
"paid_through_date": "2024-12-25",
"paid_through_date": "redacted",
"payment_method_token": "haq682e0",
"plan_id": "38py",
"price": "11.00",
Expand Down Expand Up @@ -941,7 +941,7 @@
"trial_duration": null,
"trial_duration_unit": null,
"trial_period": false,
"updated_at": "2024-11-26T16:29:00Z"
"updated_at": "redacted"
}
],
[
Expand Down
15 changes: 15 additions & 0 deletions source-braintree-native/tests/test_snapshots.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
import json
import subprocess

SUBSCRIPTION_FIELDS_TO_REDACT = [
'billing_period_end_date',
'billing_period_start_date',
'next_billing_date',
'paid_through_date',
'updated_at',
]

def test_capture(request, snapshot):
result = subprocess.run(
[
Expand Down Expand Up @@ -36,6 +44,13 @@ def test_capture(request, snapshot):
for e in evidence:
if 'url' in e:
e['url'] = 'redacted'
if stream == 'acmeCo/subscriptions':
for field in SUBSCRIPTION_FIELDS_TO_REDACT:
rec[field] = 'redacted'
rec['current_billing_cycle'] = 0

rec['status_history'] = [rec['status_history'][-1]]
rec['transactions'] = [rec['transactions'][-1]]

assert snapshot("capture.stdout.json") == unique_stream_lines

Expand Down

0 comments on commit 38ecf7b

Please sign in to comment.