Skip to content

Commit 5ee4228

Browse files
committed
tests: add integration tests for stripe
1 parent 845dd2b commit 5ee4228

File tree

1 file changed

+50
-3
lines changed

1 file changed

+50
-3
lines changed

ingestr/main_test.py

Lines changed: 50 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3612,13 +3612,58 @@ def test_s3_destination():
36123612
)
36133613

36143614

3615-
@pytest.mark.parametrize("stripe_table", ["subscription", "customer", "charge"])
3616-
def test_stripe_source(stripe_table):
3615+
@pytest.mark.parametrize(
3616+
"stripe_table",
3617+
[
3618+
"subscription",
3619+
"customer",
3620+
"product",
3621+
"price",
3622+
"event",
3623+
"invoice",
3624+
"charge",
3625+
"balancetransaction",
3626+
],
3627+
)
3628+
def test_stripe_source_full_refresh(stripe_table):
3629+
# Get Stripe token from environment
3630+
stripe_token = os.environ.get("INGESTR_TEST_STRIPE_TOKEN")
3631+
if not stripe_token:
3632+
pytest.skip("INGESTR_TEST_STRIPE_TOKEN not set")
3633+
3634+
# Create test database
3635+
dbname = f"test_stripe_{stripe_table}{get_random_string(5)}.db"
3636+
abs_db_path = get_abs_path(f"./testdata/{dbname}")
3637+
rel_db_path_to_command = f"ingestr/testdata/{dbname}"
3638+
uri = f"duckdb:///{rel_db_path_to_command}"
3639+
3640+
conn = duckdb.connect(abs_db_path)
3641+
3642+
# Run ingest command
3643+
result = invoke_ingest_command(
3644+
f"stripe://{stripe_table}s?api_key={stripe_token}",
3645+
stripe_table,
3646+
uri,
3647+
f"raw.{stripe_table}s",
3648+
)
3649+
3650+
assert result.exit_code == 0
3651+
3652+
# Verify data was loaded
3653+
res = conn.sql(f"select count(*) from raw.{stripe_table}s").fetchone()
3654+
assert res[0] > 0, f"No {stripe_table} records found"
3655+
3656+
# Clean up
36173657
try:
3618-
shutil.rmtree(get_abs_path("../pipeline_data"))
3658+
os.remove(abs_db_path)
36193659
except Exception:
36203660
pass
36213661

3662+
3663+
@pytest.mark.parametrize(
3664+
"stripe_table", ["event", "invoice", "charge", "balancetransaction"]
3665+
)
3666+
def test_stripe_source_incremental(stripe_table):
36223667
# Get Stripe token from environment
36233668
stripe_token = os.environ.get("INGESTR_TEST_STRIPE_TOKEN")
36243669
if not stripe_token:
@@ -3638,6 +3683,8 @@ def test_stripe_source(stripe_table):
36383683
stripe_table,
36393684
uri,
36403685
f"raw.{stripe_table}s",
3686+
interval_start="2025-04-01",
3687+
interval_end="2025-05-30",
36413688
)
36423689

36433690
assert result.exit_code == 0

0 commit comments

Comments
 (0)