:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
feat(data-warehouse): add 6 missing tables to the Awin source (#125135)
Tom Owers464afc96421f
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/COVERAGE_GAPS_APPENDIX.md b/products/warehouse_sources/backend/temporal/data_imports/sources/COVERAGE_GAPS_APPENDIX.mdindex 9e3fd55df0cb..8c20831aa832 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/COVERAGE_GAPS_APPENDIX.md+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/COVERAGE_GAPS_APPENDIX.md@@ -1076,10 +1076,10 @@ Diffed against: <https://help.awin.com/llms.txt>- [x] `GET publishers information for advertiser` — lookup table resolving the publisherId on every transaction and performance row (high)- [x] `GET commission groups for an advertiser` — lookup resolving the commissionGroupId carried on transactions (high)- [x] `GET programme details for publisher` — commission ranges, currency and terms per programme; programmes table only carries the summary (high)-- [ ] `GET campaign performance report (publisher and advertiser)` — revenue and clicks broken down by campaign - a core reporting dimension we do not expose (medium)-- [ ] `GET creative performance report (publisher and advertiser)` — performance by creative/banner, the other main report dimension (medium)-- [ ] `GET transaction queries for a publisher` — dispute/query state on transactions - transition history for revenue we already sync (medium)-- [ ] `GET offers/promotions` — active vouchers and promotions per programme, joinable to transactions via voucher code (medium)+- [x] `GET campaign performance report (publisher and advertiser)` — revenue and clicks broken down by campaign - a core reporting dimension we do not expose (medium) — two tables, `publisher_campaign_reports` and `advertiser_campaign_reports`, one per account side, with one row per campaign and day+- [x] `GET creative performance report (publisher and advertiser)` — performance by creative/banner, the other main report dimension (medium) — two tables, `publisher_creative_reports` and `advertiser_creative_reports`, one per account side+- [x] `GET transaction queries for a publisher` — dispute/query state on transactions - transition history for revenue we already sync (medium)+- [x] `GET offers/promotions` — active vouchers and promotions per programme, joinable to transactions via voucher code (medium) — the `offers` table reads Awin's POST promotions endpoint and keeps only the active offers of joined programmes, because the API returns no expired offers and hides voucher codes for programmes the publisher has not joined- [ ] `GET commission sharing rules for a publisher` — explains commission splits seen in transaction amounts (low)Note: The wiki.awin.com URLs in the source config are dead - they now 302 to the awin.com marketing homepage. The live reference is help.awin.com/apidocs with a machine-readable index at help.awin.com/llms.txt; the doc URLs in the source should be updated.diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/awin/awin.py b/products/warehouse_sources/backend/temporal/data_imports/sources/awin/awin.pyindex 8b429110a834..c7c18d06743e 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/awin/awin.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/awin/awin.py@@ -85,12 +85,16 @@ def _fetch(headers: dict[str, str],params: dict[str, Any],logger: FilteringBoundLogger,+ json_body: Optional[dict[str, Any]] = None,) -> Any:url = f"{AWIN_BASE_URL}{path}"if params:url = f"{url}?{urlencode(params)}"- response = session.get(url, headers=headers, timeout=REQUEST_TIMEOUT_SECONDS)+ if json_body is not None:+ response = session.post(url, headers=headers, json=json_body, timeout=REQUEST_TIMEOUT_SECONDS)+ else:+ response = session.get(url, headers=headers, timeout=REQUEST_TIMEOUT_SECONDS)if response.status_code == 429 or response.status_code >= 500:raise AwinRetryableError(f"Awin API error (retryable): status={response.status_code}, url={url}")@@ -266,6 +270,53 @@ def _rows_from_response(return rows+def _total_pages(config: AwinEndpointConfig, data: Any) -> Optional[int]:+ if not isinstance(data, dict):+ return None+ if config.paginator == "page_number":+ total_pages = data.get("totalPagesAvailable")+ return total_pages if isinstance(total_pages, int) else None+ pagination = data.get("pagination")+ total = pagination.get("total") if isinstance(pagination, dict) else None+ return -(-total // config.page_size) if isinstance(total, int) else None+++def _iter_pages(+ config: AwinEndpointConfig,+ session: requests.Session,+ path: str,+ headers: dict[str, str],+ params: dict[str, Any],+ logger: FilteringBoundLogger,+ target: AwinFanoutTarget,+) -> Iterator[list[dict[str, Any]]]:+ """Yield the rows of each page of one work item, or of its single response when unpaginated."""+ if config.paginator is None:+ yield _rows_from_response(config, _fetch(session, path, headers, params, logger), target)+ return++ page = 1+ while True:+ if config.paginator == "page_number":+ page_params = {**params, "pageNumber": str(page), "pageSize": str(config.page_size)}+ data = _fetch(session, path, headers, page_params, logger)+ else:+ body = {+ "filters": dict(config.request_filters),+ "pagination": {"page": page, "pageSize": config.page_size},+ }+ data = _fetch(session, path, headers, params, logger, json_body=body)++ rows = _rows_from_response(config, data, target)+ yield rows++ total_pages = _total_pages(config, data)+ # A short page ends the walk too, so a response without totals cannot loop forever.+ if not rows or len(rows) < config.page_size or (total_pages is not None and page >= total_pages):+ return+ page += 1++def _resume_index(work_items: list[tuple[Optional[tuple[datetime, datetime]], AwinFanoutTarget]], resume: Optional[AwinResumeConfig]) -> int:@@ -335,10 +386,9 @@ def get_rows(if config.kind == "publisher_programme_fanout":params["advertiserId"] = str(target.advertiser_id)- data = _fetch(session, _format_path(config, target), headers, params, logger)- rows = _rows_from_response(config, data, target)- if rows:- yield rows+ for rows in _iter_pages(config, session, _format_path(config, target), headers, params, logger, target):+ if rows:+ yield rows# Save after processing each work item. A crash before this line re-fetches the same item on# resume: if it yielded rows they're re-yielded and merge dedupes on the primary key; an empty# window is simply re-fetched (a no-op).diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/awin/canonical_descriptions.py b/products/warehouse_sources/backend/temporal/data_imports/sources/awin/canonical_descriptions.pyindex 3860868d8cab..1c1eedad3827 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/awin/canonical_descriptions.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/awin/canonical_descriptions.py@@ -129,4 +129,99 @@ CANONICAL_DESCRIPTIONS: CanonicalDescriptions = {"primaryType": "The publisher's primary promotion type.",},},+ "publisher_campaign_reports": {+ "description": "Daily clicks and transactions for a publisher account, aggregated per advertiser and campaign tracking value.",+ "docs_url": "https://help.awin.com/apidocs/get-campaign-data-for-publisher-report",+ "columns": {+ "publisherId": "Publisher account the report was pulled for.",+ "advertiserId": "Advertiser the clicks and transactions belong to.",+ "advertiserName": "Name of the advertiser.",+ "campaign": "Value of the campaign tracking parameter the numbers are aggregated by.",+ "date": "Day the numbers are aggregated over.",+ "quantity": "Number of clicks and transactions, split by commission status.",+ "saleAmount": "Value of the transactions, split by commission status.",+ "commissionAmount": "Commission on the transactions, split by commission status.",+ },+ },+ "advertiser_campaign_reports": {+ "description": "Daily clicks and transactions for an advertiser account, aggregated per publisher and campaign tracking value.",+ "docs_url": "https://help.awin.com/apidocs/get-campaign-data-for-advertiser-report",+ "columns": {+ "advertiserId": "Advertiser account the report was pulled for.",+ "publisherId": "Publisher that drove the clicks and transactions.",+ "publisherName": "Name of the publisher.",+ "campaign": "Value of the campaign tracking parameter the numbers are aggregated by.",+ "date": "Day the numbers are aggregated over.",+ "quantity": "Number of clicks and transactions, split by commission status.",+ "saleAmount": "Value of the transactions, split by commission status.",+ "commissionAmount": "Commission on the transactions, split by commission status.",+ },+ },+ "publisher_creative_reports": {+ "description": "Impressions, clicks and transactions per creative a publisher account used, aggregated over the report window.",+ "docs_url": "https://help.awin.com/apidocs/get-publisher-creative-performance-report",+ "columns": {+ "publisherId": "Publisher account that used the creative.",+ "advertiserId": "Advertiser that owns the creative.",+ "creativeId": "Unique identifier of the creative.",+ "creativeName": "Name of the creative.",+ "tagName": "Tag the advertiser uses to group creatives.",+ "impressions": "Number of impressions.",+ "clicks": "Number of clicks.",+ "totalNo": "Total number of transactions.",+ "totalValue": "Value of all transactions.",+ "totalComm": "Commission on all transactions.",+ },+ },+ "advertiser_creative_reports": {+ "description": "Impressions, clicks and transactions per creative of an advertiser account, aggregated per publisher over the report window.",+ "docs_url": "https://help.awin.com/apidocs/get-advertiser-creative-performance-report",+ "columns": {+ "advertiserId": "Advertiser account that owns the creative.",+ "publisherId": "Publisher that used the creative.",+ "creativeId": "Unique identifier of the creative.",+ "creativeName": "Name of the creative.",+ "tagName": "Tag the advertiser uses to group creatives.",+ "impressions": "Number of impressions.",+ "clicks": "Number of clicks.",+ "totalNo": "Total number of transactions.",+ "totalValue": "Value of all transactions.",+ "totalComm": "Commission on all transactions.",+ },+ },+ "transaction_queries": {+ "description": "Queries a publisher account raised about missing or incorrect transactions, with their current status.",+ "docs_url": "https://help.awin.com/apidocs/fetch-list-of-transaction-queries-for-a-given-publisher",+ "columns": {+ "publisherId": "Publisher account that raised the query.",+ "enquiryId": "Unique identifier of the transaction query.",+ "enquiryDate": "When the query was raised.",+ "enquiryStatus": "Current status of the query (e.g. pending, approved, declined).",+ "enquiryType": "Kind of query raised.",+ "advertiserId": "Advertiser the queried transaction was placed with.",+ "clickRef": "Click reference the publisher attached to the click.",+ "orderRef": "Advertiser's order reference for the transaction.",+ "transactionDate": "When the queried transaction happened.",+ "validationDate": "When the queried transaction was validated.",+ "declineReason": "Why the query was declined, when it was.",+ "saleAmount": "Order value of the queried transaction, as an {amount, currency} object.",+ "commissionAmount": "Commission claimed for the queried transaction, as an {amount, currency} object.",+ },+ },+ "offers": {+ "description": "Active promotions and voucher codes from the advertiser programmes a publisher account has joined.",+ "docs_url": "https://help.awin.com/apidocs/promotions",+ "columns": {+ "publisherId": "Publisher account the offers were pulled for.",+ "promotionId": "Unique identifier of the offer.",+ "type": "Whether the offer is a 'promotion' or a 'voucher'.",+ "advertiser": "Advertiser that published the offer, as an {id, name, joined} object.",+ "title": "Title of the offer.",+ "startDate": "Start of the period the offer is valid in, in UTC.",+ "endDate": "End of the period the offer is valid in, in UTC.",+ "dateAdded": "When the offer was added to the Awin network, in UTC.",+ "voucher": "Voucher details for voucher offers, as a {code, exclusive, attributable} object.",+ "regions": "Regions the offer applies in.",+ },+ },}diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/awin/settings.py b/products/warehouse_sources/backend/temporal/data_imports/sources/awin/settings.pyindex 4894f7135a04..7d3814d0e5ac 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/awin/settings.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/awin/settings.py@@ -22,6 +22,11 @@ DEFAULT_REPORT_LOOKBACK_DAYS = 30# last kind is for publisher-scoped paths that also require an advertiserId query param.AwinEndpointKind = Literal["accounts", "publisher_fanout", "advertiser_fanout", "publisher_programme_fanout"]+# `page_number` sends pageNumber/pageSize query params and reads `totalPagesAvailable` (transaction+# queries). `promotions` sends a {"filters", "pagination"} POST body and reads `pagination.total`+# (offers).+AwinPaginator = Literal["page_number", "promotions"]+# Awin's aggregated report endpoints require a `region` query param naming the account's market# (there is no "all regions" value). Options and default ("GB") match Awin's own API docs.REGION_OPTIONS: list[tuple[str, str]] = [@@ -87,6 +92,10 @@ class AwinEndpointConfig:# Whether this endpoint needs the account's `region` in its query params. Only Awin's# publisher-side aggregated report requires it; the advertiser-side report does not.requires_region: bool = False+ paginator: Optional[AwinPaginator] = None+ page_size: int = 100+ # Filters sent in the POST body of the offers endpoint, which takes no query params.+ request_filters: dict[str, str] = field(default_factory=dict)should_sync_default: bool = True@@ -195,6 +204,94 @@ AWIN_ENDPOINTS: dict[str, AwinEndpointConfig] = {primary_keys=["advertiserId", "id"],inject_advertiser_id=True,),+ "publisher_campaign_reports": AwinEndpointConfig(+ name="publisher_campaign_reports",+ kind="publisher_fanout",+ path="/publishers/{publisher_id}/reports/campaign",+ # `interval=day` splits the totals into one row per day, so `date` is part of the key.+ primary_keys=["publisherId", "advertiserId", "campaign", "date"],+ inject_publisher_id=True,+ extra_params={"interval": "day"},+ date_windowed=True,+ date_format="%Y-%m-%d",+ report_lookback_days=DEFAULT_REPORT_LOOKBACK_DAYS,+ requires_region=True,+ ),+ "advertiser_campaign_reports": AwinEndpointConfig(+ name="advertiser_campaign_reports",+ kind="advertiser_fanout",+ path="/advertisers/{advertiser_id}/reports/campaign",+ primary_keys=["advertiserId", "publisherId", "campaign", "date"],+ inject_advertiser_id=True,+ extra_params={"interval": "day"},+ date_windowed=True,+ date_format="%Y-%m-%d",+ report_lookback_days=DEFAULT_REPORT_LOOKBACK_DAYS,+ ),+ "publisher_creative_reports": AwinEndpointConfig(+ name="publisher_creative_reports",+ kind="publisher_fanout",+ path="/publishers/{publisher_id}/reports/creative",+ primary_keys=["publisherId", "advertiserId", "creativeId"],+ inject_publisher_id=True,+ date_windowed=True,+ date_format="%Y-%m-%d",+ report_lookback_days=DEFAULT_REPORT_LOOKBACK_DAYS,+ requires_region=True,+ ),+ "advertiser_creative_reports": AwinEndpointConfig(+ name="advertiser_creative_reports",+ kind="advertiser_fanout",+ path="/advertisers/{advertiser_id}/reports/creative",+ primary_keys=["advertiserId", "publisherId", "creativeId"],+ inject_advertiser_id=True,+ date_windowed=True,+ date_format="%Y-%m-%d",+ report_lookback_days=DEFAULT_REPORT_LOOKBACK_DAYS,+ requires_region=True,+ ),+ "transaction_queries": AwinEndpointConfig(+ name="transaction_queries",+ kind="publisher_fanout",+ # Awin serves this one under the singular `/publisher/` prefix.+ path="/publisher/{publisher_id}/transactionqueries",+ primary_keys=["publisherId", "enquiryId"],+ data_key="pageItems",+ inject_publisher_id=True,+ date_windowed=True,+ date_format="%Y-%m-%dT%H:%M:%S",+ incremental_fields=[+ {+ "label": "enquiryDate",+ "type": IncrementalFieldType.DateTime,+ "field": "enquiryDate",+ "field_type": IncrementalFieldType.DateTime,+ },+ {+ "label": "transactionDate",+ "type": IncrementalFieldType.DateTime,+ "field": "transactionDate",+ "field_type": IncrementalFieldType.DateTime,+ },+ ],+ date_type_by_field={"enquiryDate": "enquiryDate", "transactionDate": "transactionDate"},+ partition_key="enquiryDate",+ paginator="page_number",+ page_size=500,+ ),+ "offers": AwinEndpointConfig(+ name="offers",+ kind="publisher_fanout",+ path="/publisher/{publisher_id}/promotions",+ primary_keys=["publisherId", "promotionId"],+ data_key="data",+ inject_publisher_id=True,+ paginator="promotions",+ page_size=200,+ # Voucher codes are hidden for programmes the publisher has not joined, so only joined+ # programmes are worth syncing. Awin offers no status that covers expired offers.+ request_filters={"membership": "joined", "status": "active"},+ ),}ENDPOINTS = tuple(AWIN_ENDPOINTS.keys())diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/awin/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/awin/source.pyindex 4d961952eae8..1378bcc35bed 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/awin/source.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/awin/source.py@@ -74,7 +74,7 @@ Create a personal OAuth2 token from the [Awin API settings](https://ui.awin.com/label="Region",required=True,defaultValue=DEFAULT_REGION,- caption="Your Awin account's primary region. Used to sync the advertiser performance report.",+ caption="Your Awin account's primary region. Used to sync the performance reports.",options=[SourceFieldSelectConfigOption(label=label, value=value) for value, label in REGION_OPTIONS],@@ -114,7 +114,13 @@ Create a personal OAuth2 token from the [Awin API settings](https://ui.awin.com/return "Full refresh only. Needs an advertiser account"if endpoint in ("commission_groups", "programme_details"):return "Full refresh only. Takes one request per joined programme, so it syncs slowly if your publisher accounts are in many programmes"- if endpoint == "transactions":+ if endpoint in ("publisher_campaign_reports", "publisher_creative_reports"):+ return "Full refresh only. A rolling snapshot of the last 30 days of performance for your publisher accounts"+ if endpoint in ("advertiser_campaign_reports", "advertiser_creative_reports"):+ return "Full refresh only. A rolling snapshot of the last 30 days of performance. Needs an advertiser account"+ if endpoint == "offers":+ return "Full refresh only. Active offers and voucher codes from the programmes your publisher accounts have joined"+ if endpoint in ("transactions", "transaction_queries"):return "Only syncs the last 365 days on initial sync"return Nonediff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/awin/tests/test_awin.py b/products/warehouse_sources/backend/temporal/data_imports/sources/awin/tests/test_awin.pyindex c41937efdccd..dd2fd3a66672 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/awin/tests/test_awin.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/awin/tests/test_awin.py@@ -1,7 +1,9 @@+from dataclasses import replacefrom datetime import UTC, datetimefrom typing import Any, Optionalimport time_machine+from unittest.mock import patchfrom parameterized import parameterized@@ -65,17 +67,52 @@ class TestWindowsForAccount:class TestBuildWindowParams:- def test_reports_advertiser_includes_region(self) -> None:- # Awin's aggregated advertiser report 400s without `region` because it's a required param- # the API has no "all regions" value for.+ @parameterized.expand(+ [+ # Awin's aggregated reports 400 without `region` where it is a required param, because+ # the API has no "all regions" value for it.+ ("reports_advertiser", "US", None),+ ("publisher_campaign_reports", "US", "day"),+ ("advertiser_campaign_reports", None, "day"),+ ("publisher_creative_reports", "US", None),+ ("advertiser_creative_reports", "US", None),+ ]+ )+ def test_report_params(+ self, endpoint: str, expected_region: Optional[str], expected_interval: Optional[str]+ ) -> None:params = _build_window_params(- AWIN_ENDPOINTS["reports_advertiser"],+ AWIN_ENDPOINTS[endpoint],datetime(2024, 1, 1, tzinfo=UTC),datetime(2024, 1, 31, tzinfo=UTC),incremental_field=None,region="US",)- assert params["region"] == "US"+ assert params.get("region") == expected_region+ # Without a daily interval the campaign report returns one total per campaign, which the+ # `date` primary key column cannot tell apart.+ assert params.get("interval") == expected_interval+ assert params["startDate"] == "2024-01-01"++ @parameterized.expand(+ [+ ("default", None, "enquiryDate"),+ ("enquiry_date", "enquiryDate", "enquiryDate"),+ ("transaction_date", "transactionDate", "transactionDate"),+ ]+ )+ def test_transaction_queries_window_on_the_selected_field(+ self, _name: str, incremental_field: Optional[str], expected_date_type: str+ ) -> None:+ params = _build_window_params(+ AWIN_ENDPOINTS["transaction_queries"],+ datetime(2024, 1, 1, tzinfo=UTC),+ datetime(2024, 1, 31, tzinfo=UTC),+ incremental_field=incremental_field,+ region="US",+ )+ assert params["dateType"] == expected_date_type+ assert params["startDate"] == "2024-01-01T00:00:00"class TestRowsFromResponse:@@ -165,6 +202,9 @@ class TestFormatPath:),("reports_publisher", AwinFanoutTarget(advertiser_id=9), "/advertisers/9/reports/publisher"),("advertiser_publishers", AwinFanoutTarget(advertiser_id=9), "/advertisers/9/publishers"),+ # Awin serves these two under the singular `/publisher/` prefix.+ ("transaction_queries", AwinFanoutTarget(publisher_id=5), "/publisher/5/transactionqueries"),+ ("offers", AwinFanoutTarget(publisher_id=5), "/publisher/5/promotions"),])def test_each_id_lands_in_the_path_segment_that_accepts_it(@@ -278,6 +318,75 @@ class TestGetRows:assert result.params("advertiserId")[2:] == ["2", "3"]+class TestPaginatedEndpoints:+ @parameterized.expand(+ [+ # The last page is full, so only the page count stops the walk.+ ("stops_at_total_pages", [2, 2], 2, ["1", "2"]),+ # No totals in the body, so the short second page ends the walk.+ ("stops_at_short_page", [2, 1], None, ["1", "2"]),+ ("stops_at_empty_page", [0], None, ["1"]),+ ]+ )+ @time_machine.travel("2024-06-01", tick=False)+ def test_transaction_queries_walk_every_page_of_each_window(+ self, _name: str, page_lengths: list[int], total_pages: Optional[int], expected_pages: list[str]+ ) -> None:+ page_iter = iter(page_lengths)+ next_enquiry_id = iter(range(1, 1000))++ def answer(request: RecordedRequest) -> ScriptedResponse:+ if request.path == "/accounts":+ return ScriptedResponse(json={"accounts": [{"accountId": 10, "accountType": "publisher"}]})+ items = [{"enquiryId": next(next_enquiry_id)} for _ in range(next(page_iter))]+ body: dict[str, Any] = {"pageItems": items}+ if total_pages is not None:+ body["totalPagesAvailable"] = total_pages+ return ScriptedResponse(json=body)++ with patch.dict(+ AWIN_ENDPOINTS, {"transaction_queries": replace(AWIN_ENDPOINTS["transaction_queries"], page_size=2)}+ ):+ # A recent cursor leaves a single window, so every request below is a page of it.+ result = SourceDriver(AwinSource(), AwinSourceConfig(api_token="token")).run(+ "transaction_queries",+ answer,+ should_use_incremental_field=True,+ incremental_field="enquiryDate",+ db_incremental_field_last_value="2024-05-20T00:00:00",+ )++ assert result.raised is None+ assert result.params("pageNumber")[1:] == expected_pages+ assert set(result.params("startDate")[1:]) == {"2024-05-20T00:00:00"}+ assert {r.path for r in result.requests[1:]} == {"/publisher/10/transactionqueries"}+ assert [row["enquiryId"] for row in result.rows] == list(range(1, sum(page_lengths) + 1))+ assert all(row["publisherId"] == 10 for row in result.rows)++ def test_offers_post_filters_and_page_through_the_total(self) -> None:+ def offers(start: int, count: int) -> list[dict[str, Any]]:+ return [{"promotionId": promotion_id} for promotion_id in range(start, start + count)]++ with patch.dict(AWIN_ENDPOINTS, {"offers": replace(AWIN_ENDPOINTS["offers"], page_size=2)}):+ result = SourceDriver(AwinSource(), AwinSourceConfig(api_token="token")).run(+ "offers",+ [+ ScriptedResponse(json={"accounts": [{"accountId": 10, "accountType": "publisher"}]}),+ ScriptedResponse(json={"data": offers(1, 2), "pagination": {"page": 1, "pageSize": 2, "total": 4}}),+ ScriptedResponse(json={"data": offers(3, 2), "pagination": {"page": 2, "pageSize": 2, "total": 4}}),+ ],+ )++ assert result.raised is None+ offer_requests = result.requests[1:]+ assert [(r.method, r.path) for r in offer_requests] == [("POST", "/publisher/10/promotions")] * 2+ assert [r.json() for r in offer_requests] == [+ {"filters": {"membership": "joined", "status": "active"}, "pagination": {"page": page, "pageSize": 2}}+ for page in (1, 2)+ ]+ assert result.rows == [{"promotionId": promotion_id, "publisherId": 10} for promotion_id in range(1, 5)]++class TestAwinSource:@parameterized.expand([