feat(pchome): automate authorized sales acquisition
Some checks failed
CD Pipeline / deploy (push) Has been cancelled

This commit is contained in:
ogt
2026-07-11 01:30:42 +08:00
parent f68223f0ed
commit 6e65ef00bb
21 changed files with 2428 additions and 617 deletions

View File

@@ -29,11 +29,23 @@ def test_daily_snapshot_delete_casts_text_date_column_on_postgres(monkeypatch):
def test_daily_snapshot_delete_query_uses_snapshot_date_cast_helper():
source = Path("services/import_service.py").read_text(encoding="utf-8")
assert 'snapshot_date_expr = _date_filter_expr("snapshot_date")' in source
assert "DELETE FROM {table_name} WHERE {snapshot_date_expr} IN" in source
assert 'snapshot_expr = _date_filter_expr("snapshot_date")' in source
assert "f\"WHERE {snapshot_expr} IN ({snapshot_placeholders})\"" in source
assert "DELETE FROM daily_sales_snapshot WHERE snapshot_date IN" not in source
def test_sales_table_replacement_uses_one_transaction_connection():
source = Path("services/import_service.py").read_text(encoding="utf-8")
start = source.index("def _replace_sales_tables_atomic")
end = source.index("# 資料庫設定", start)
block = source[start:end]
assert "with engine.begin() as conn:" in block
assert 'df.to_sql(\n "daily_sales_snapshot",\n conn,' in block
assert 'df_monthly.to_sql(\n "realtime_sales_monthly",\n conn,' in block
assert "conn.commit()" not in block
def test_daily_snapshot_delete_uses_iso_dates_on_sqlite(monkeypatch):
monkeypatch.setattr(import_service, "_db_dialect_name", lambda: "sqlite")