diff --git a/docs/diagrams/bedrock_basket_ctms_acoustic.md b/docs/diagrams/bedrock_basket_ctms_acoustic.md index 130713b0..c0f6cdb1 100644 --- a/docs/diagrams/bedrock_basket_ctms_acoustic.md +++ b/docs/diagrams/bedrock_basket_ctms_acoustic.md @@ -19,28 +19,28 @@ sequenceDiagram %% https://github.com/mozilla/bedrock/blob/ecba76406ed35c04d35532c3ed7562b09d65fabe/bedrock/products/views.py#L68-L87 Basket->>Basket Task: Spawn task - %% https://github.com/mozmeao/basket/blob/77f98bb63c70cecbb3ec8d69b512df67abce8c63/basket/news/views.py#L681 + %% https://github.com/mozmeao/basket/blob/2023-07-06/basket/news/views.py#L681 Basket-->>Bedrock: [status] Bedrock-->>Visitor: . rect rgb(240,240,240) Basket Task->>Basket Task: Process data - %% https://github.com/mozmeao/basket/blob/77f98bb63c70cecbb3ec8d69b512df67abce8c63/basket/news/backends/ctms.py#L199 + %% https://github.com/mozmeao/basket/blob/2023-07-06/basket/news/backends/ctms.py#L263 Basket Task->>CTMS: update(token, email_id, newsletters, fpn_platform, fpn_country) - %% https://github.com/mozmeao/basket/blob/77f98bb63c70cecbb3ec8d69b512df67abce8c63/basket/news/tasks.py#L654 - %% https://github.com/mozilla-it/ctms-api/blob/6f903aeb90b65c170f34485e1cc4b3755839daaf/ctms/crud.py#L563 + %% https://github.com/mozmeao/basket/blob/2023-07-06/basket/news/tasks.py#L401 + %% https://github.com/mozilla-it/ctms-api/blob/v2.1.0/ctms/crud.py#L579 CTMS-->>Basket Task: . end rect rgb(240,240,240) CTMS Sync->>CTMS Sync: Flatten fields - %% https://github.com/mozilla-it/ctms-api/blob/cde9694e2992c2c9d8315ba9c6954c50a6facf37/ctms/acoustic_service.py#L62 + %% https://github.com/mozilla-it/ctms-api/blob/v2.1.0/ctms/acoustic_service.py#L141 CTMS Sync->>Acoustic: sync_records() - %% https://github.com/mozilla-it/ctms-api/blob/cde9694e2992c2c9d8315ba9c6954c50a6facf37/ctms/bin/acoustic_sync.py + %% https://github.com/mozilla-it/ctms-api/blob/v2.1.0/ctms/bin/acoustic_sync.py end ``` @@ -119,10 +119,17 @@ CTMS create contact ([`POST /ctms`](https://github.com/mozilla-it/ctms-api/blob/ "lang": "fr", } ], - "vpn_waitlist": { - "geo": "fr", - "platform": "ios,mac", - }, + "waitlist": [ + { + "name": "vpn", + "subscribed": True, + "source": "https://vpn.mozilla.org/fr", + "fields": { + "geo": "fr", + "platform": "ios,mac" + } + } + ] } ``` diff --git a/tests/integration/test_basket_waitlist_subscription.py b/tests/integration/test_basket_waitlist_subscription.py index 979e3ddc..a0bd834d 100644 --- a/tests/integration/test_basket_waitlist_subscription.py +++ b/tests/integration/test_basket_waitlist_subscription.py @@ -139,6 +139,7 @@ def fetch_created(): "unsub_reason": None, } ] + # Legacy (read-only) fields. assert contact_details["vpn_waitlist"] == { "geo": "us", "platform": "ios,android", @@ -150,17 +151,18 @@ def fetch_created(): f"{settings.ctms_server_url}/ctms/{email_id}", headers=ctms_headers, json={ - "vpn_waitlist": {"geo": "fr", "platform": "linux"}, + "waitlists": [ + { + "name": "vpn", + "fields": {"geo": "fr", "platform": "linux"}, + } + ], }, ) resp.raise_for_status() # Request the full contact details again. contact_details = ctms_fetch(email, ctms_headers) assert contact_details["newsletters"] == [] - assert contact_details["vpn_waitlist"] == { - "geo": "fr", - "platform": "linux", - } assert contact_details["waitlists"] == [ { "name": "vpn", @@ -173,6 +175,11 @@ def fetch_created(): "unsub_reason": None, } ] + # Legacy (read-only) fields. + assert contact_details["vpn_waitlist"] == { + "geo": "fr", + "platform": "linux", + } # 4. Unsubscribe via Basket basket_token = contact_details["email"]["basket_token"] @@ -185,6 +192,7 @@ def check_updated(): contact_details = ctms_fetch(email, ctms_headers) assert contact_details["newsletters"] == [] assert not contact_details["waitlists"][0]["subscribed"] + # Legacy (read-only) fields. assert contact_details["vpn_waitlist"] == { "geo": None, "platform": None, @@ -225,6 +233,7 @@ def fetch_created(): "unsub_reason": None, } ] + # Legacy (read-only) fields. assert contact_details["relay_waitlist"] == { "geo": "es", } @@ -267,9 +276,9 @@ def check_subscribed(): "unsub_reason": None, }, ] + # Legacy (read-only) fields. # If multiple `relay-` waitlists are present, the `geo` field of the - # first waitlist is set as the value of `relay_waitlist["geo"]`. This - # property is intended for legacy consumers + # first waitlist is set as the value of `relay_waitlist["geo"]`. assert contact_details["relay_waitlist"] == { "geo": "es", } @@ -307,6 +316,7 @@ def check_unsubscribed(): "unsub_reason": None, }, ] + # Legacy (read-only) fields. # relay_waitlist geo is pulled from the remaining waitlist. assert contact_details["relay_waitlist"] == { "geo": "fr", @@ -325,5 +335,6 @@ def check_unsubscribed_last(): contact_details = check_unsubscribed_last() assert contact_details["newsletters"] == [] + # Legacy (read-only) fields. # Relay attribute is now empty assert contact_details["relay_waitlist"] == {"geo": None}