-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
When unsent, this defaults to "H" in CTMS.
- Loading branch information
Showing
6 changed files
with
18 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,7 +16,6 @@ def test_normal(self, get_user_data, ctms_mock): | |
"status": "ok", | ||
"optin": False, | ||
"newsletters": Mock(), | ||
"format": "ZZ", | ||
"email": "[email protected]", | ||
"token": token, | ||
"email_id": "some-email-id", | ||
|
@@ -31,7 +30,6 @@ def test_already_confirmed(self, get_user_data, ctms_mock): | |
"status": "ok", | ||
"optin": True, | ||
"newsletters": Mock(), | ||
"format": "ZZ", | ||
} | ||
get_user_data.return_value = user_data | ||
token = "TOKEN" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -127,7 +127,6 @@ | |
"email": "[email protected]", | ||
"email_id": "332de237-cab7-4461-bcc3-48e68f42bd5c", | ||
"first_name": "Jane", | ||
"format": "H", | ||
"fpn_country": "fr", | ||
"fpn_platform": "ios,mac", | ||
"relay_country": "fr", | ||
|
@@ -224,7 +223,6 @@ def test_sample_format(self, mock_nl_slugs, mock_wl_slugs): | |
"basket_token": "c4a7d759-bb52-457b-896b-90f1d3ef8433", | ||
"create_timestamp": "2020-03-28T15:41:00.000Z", | ||
"double_opt_in": True, | ||
"email_format": "H", | ||
"email_id": "332de237-cab7-4461-bcc3-48e68f42bd5c", | ||
"email_lang": "en", | ||
"first_name": "Jane", | ||
|
@@ -249,7 +247,6 @@ def test_sample_format(self, mock_nl_slugs, mock_wl_slugs): | |
{ | ||
"name": "mozilla-welcome", | ||
"subscribed": True, | ||
"format": "H", | ||
"lang": "en", | ||
}, | ||
], | ||
|
@@ -415,30 +412,26 @@ def test_newsletter_list_with_extra_data(self, mock_nl_slugs, mock_langs): | |
"newsletters": ["slug1", "slug2", "slug3", "other"], | ||
"source_url": " https://example.com", | ||
"lang": "es", | ||
"format": "T", | ||
} | ||
prepared = to_vendor(data) | ||
assert prepared == { | ||
"email": {"email_format": "T", "email_lang": "es"}, | ||
"email": {"email_lang": "es"}, | ||
"newsletters": [ | ||
{ | ||
"name": "slug1", | ||
"subscribed": True, | ||
"format": "T", | ||
"lang": "es", | ||
"source": "https://example.com", | ||
}, | ||
{ | ||
"name": "slug2", | ||
"subscribed": True, | ||
"format": "T", | ||
"lang": "es", | ||
"source": "https://example.com", | ||
}, | ||
{ | ||
"name": "slug3", | ||
"subscribed": True, | ||
"format": "T", | ||
"lang": "es", | ||
"source": "https://example.com", | ||
}, | ||
|
@@ -448,27 +441,27 @@ def test_newsletter_list_with_extra_data(self, mock_nl_slugs, mock_langs): | |
@patch("basket.news.newsletters.newsletter_languages", return_value=["en", "fr"]) | ||
@patch("basket.news.backends.ctms.newsletter_slugs", return_value=["slug1"]) | ||
def test_newsletter_list_with_defaults(self, mock_nl_slugs, mock_langs): | ||
"""A newsletter list uses the default language and format""" | ||
"""A newsletter list uses the default language""" | ||
data = {"newsletters": ["slug1"]} | ||
existing_data = {"lang": "fr", "format": "H"} | ||
existing_data = {"lang": "fr"} | ||
prepared = to_vendor(data, existing_data) | ||
assert prepared == { | ||
"newsletters": [ | ||
{"name": "slug1", "subscribed": True, "format": "H", "lang": "fr"}, | ||
{"name": "slug1", "subscribed": True, "lang": "fr"}, | ||
], | ||
} | ||
|
||
@patch("basket.news.newsletters.newsletter_languages", return_value=["en", "fr"]) | ||
@patch("basket.news.backends.ctms.newsletter_slugs", return_value=["slug1"]) | ||
def test_newsletter_list_with_defaults_override(self, mock_nl_slugs, mock_langs): | ||
"""A newsletter list uses the updated data rather than the defaults""" | ||
data = {"lang": "en", "format": "T", "newsletters": ["slug1"]} | ||
existing_data = {"lang": "fr", "format": "H"} | ||
data = {"lang": "en", "newsletters": ["slug1"]} | ||
existing_data = {"lang": "fr"} | ||
prepared = to_vendor(data, existing_data) | ||
assert prepared == { | ||
"email": {"email_format": "T", "email_lang": "en"}, | ||
"email": {"email_lang": "en"}, | ||
"newsletters": [ | ||
{"name": "slug1", "subscribed": True, "format": "T", "lang": "en"}, | ||
{"name": "slug1", "subscribed": True, "lang": "en"}, | ||
], | ||
} | ||
|
||
|
@@ -527,24 +520,21 @@ def test_newsletter_map_with_extra_data(self, mock_nl_slugs, mock_langs): | |
}, | ||
"source_url": " https://example.com", | ||
"lang": "es", | ||
"format": "T", | ||
} | ||
prepared = to_vendor(data) | ||
assert prepared == { | ||
"email": {"email_format": "T", "email_lang": "es"}, | ||
"email": {"email_lang": "es"}, | ||
"newsletters": [ | ||
{ | ||
"name": "slug1", | ||
"subscribed": True, | ||
"format": "T", | ||
"lang": "es", | ||
"source": "https://example.com", | ||
}, | ||
{"name": "slug2", "subscribed": False}, | ||
{ | ||
"name": "slug3", | ||
"subscribed": True, | ||
"format": "T", | ||
"lang": "es", | ||
"source": "https://example.com", | ||
}, | ||
|
@@ -1514,8 +1504,8 @@ def test_update_email_id_not_in_existing_data(self): | |
|
||
@patch("basket.news.newsletters.newsletter_languages", return_value=["en", "fr"]) | ||
@patch("basket.news.backends.ctms.newsletter_slugs", return_value=["slug1"]) | ||
def test_update_use_existing_lang_and_format(self, mock_slugs, mock_langs): | ||
"""CTMS.update uses the existing language and format""" | ||
def test_update_use_existing_lang(self, mock_slugs, mock_langs): | ||
"""CTMS.update uses the existing language""" | ||
updated = {"updated": "fake_response"} | ||
interface = mock_interface("PATCH", 200, updated) | ||
ctms = CTMS(interface) | ||
|
@@ -1524,15 +1514,14 @@ def test_update_use_existing_lang_and_format(self, mock_slugs, mock_langs): | |
"token": "an-existing-user", | ||
"email_id": "an-existing-id", | ||
"lang": "fr", | ||
"format": "T", | ||
} | ||
update_data = {"newsletters": ["slug1"]} | ||
assert ctms.update(user_data, update_data) == updated | ||
interface.session.patch.assert_called_once_with( | ||
"/ctms/an-existing-id", | ||
json={ | ||
"newsletters": [ | ||
{"name": "slug1", "subscribed": True, "lang": "fr", "format": "T"}, | ||
{"name": "slug1", "subscribed": True, "lang": "fr"}, | ||
], | ||
}, | ||
) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -347,6 +347,8 @@ def test_success_with_email(self): | |
"newsletters": "news,lets", | ||
"optin": "N", | ||
"sync": "N", | ||
# Throwing `format` in here to ensure backwards compatibility. | ||
"format": "H", | ||
"email": "[email protected]", | ||
"first_name": "The", | ||
"last_name": "Dude", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters