-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove more complex / indirect fixtures used in tests (#975)
* Move fixtures and constants from conftest to modules * Remove use of `sample_contacts` fixture * Remove test get for maximal contact test This is largely covered by the "example" test * Switch default email format to HTML in email factory * Remove minimal / maximal contacts * Remove now-unused fixtures
- Loading branch information
1 parent
19b748d
commit 72b8224
Showing
8 changed files
with
174 additions
and
330 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
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 |
---|---|---|
|
@@ -7,7 +7,6 @@ | |
|
||
from ctms.schemas import ContactInSchema, ContactSchema, NewsletterInSchema | ||
from ctms.schemas.waitlist import WaitlistInSchema | ||
from tests.unit.conftest import SAMPLE_CONTACT_PARAMS | ||
|
||
API_TEST_CASES = ( | ||
("GET", "/ctms", {"primary_email": "[email protected]"}), | ||
|
@@ -176,6 +175,17 @@ def find_default_fields(contact: ContactSchema) -> Set[str]: | |
return default_fields | ||
|
||
|
||
SAMPLE_CONTACT_PARAMS = [ | ||
("minimal_contact_data", set()), | ||
("maximal_contact_data", set()), | ||
("example_contact_data", set()), | ||
("to_add_contact_data", set()), | ||
("simple_default_contact_data", {"amo"}), | ||
("default_newsletter_contact_data", {"newsletters"}), | ||
("default_waitlist_contact_data", {"waitlists"}), | ||
] | ||
|
||
|
||
@pytest.mark.parametrize("post_contact", SAMPLE_CONTACT_PARAMS, indirect=True) | ||
def test_post_get_put(client, post_contact, put_contact, update_fetched): | ||
"""This encompasses the entire expected flow for basket""" | ||
|
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 |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
import pytest | ||
|
||
|
||
def test_get_ctms_for_minimal_contact(client, email_factory): | ||
def test_get_ctms_for_mostly_empty(client, email_factory): | ||
"""GET /ctms/{email_id} returns a contact with most fields unset.""" | ||
contact = email_factory(newsletters=1) | ||
newsletter = contact.newsletters[0] | ||
|
@@ -74,171 +74,6 @@ def test_get_ctms_for_minimal_contact(client, email_factory): | |
} | ||
|
||
|
||
def test_get_ctms_for_maximal_contact(client, maximal_contact): | ||
"""GET /ctms/{email_id} returns a contact with almost all fields set.""" | ||
email_id = maximal_contact.email.email_id | ||
resp = client.get(f"/ctms/{email_id}") | ||
assert resp.status_code == 200 | ||
assert resp.json() == { | ||
"amo": { | ||
"add_on_ids": "fanfox,foxfan", | ||
"create_timestamp": "2017-05-12T15:16:00+00:00", | ||
"display_name": "#1 Mozilla Fan", | ||
"email_opt_in": True, | ||
"language": "fr,en", | ||
"last_login": "2020-01-27", | ||
"location": "The Inter", | ||
"profile_url": "firefox/user/14508209", | ||
"update_timestamp": "2020-01-27T14:25:43+00:00", | ||
"user": True, | ||
"user_id": "123", | ||
"username": "Mozilla1Fan", | ||
}, | ||
"email": { | ||
"basket_token": "d9ba6182-f5dd-4728-a477-2cc11bf62b69", | ||
"create_timestamp": "2010-01-01T08:04:00+00:00", | ||
"double_opt_in": True, | ||
"email_format": "H", | ||
"email_id": "67e52c77-950f-4f28-accb-bb3ea1a2c51a", | ||
"email_lang": "fr", | ||
"first_name": "Fan", | ||
"has_opted_out_of_email": False, | ||
"last_name": "of Mozilla", | ||
"mailing_country": "ca", | ||
"primary_email": "[email protected]", | ||
"sfdc_id": "001A000001aMozFan", | ||
"unsubscribe_reason": "done with this mailing list", | ||
"update_timestamp": "2020-01-28T14:50:00+00:00", | ||
}, | ||
"fxa": { | ||
"created_date": "2019-05-22T08:29:31.906094+00:00", | ||
"account_deleted": False, | ||
"first_service": "monitor", | ||
"fxa_id": "611b6788-2bba-42a6-98c9-9ce6eb9cbd34", | ||
"lang": "fr,fr-CA", | ||
"primary_email": "[email protected]", | ||
}, | ||
"mofo": { | ||
"mofo_contact_id": "5e499cc0-eeb5-4f0e-aae6-a101721874b8", | ||
"mofo_email_id": "195207d2-63f2-4c9f-b149-80e9c408477a", | ||
"mofo_relevant": True, | ||
}, | ||
"newsletters": [ | ||
{ | ||
"format": "H", | ||
"lang": "en", | ||
"name": "ambassadors", | ||
"source": "https://www.mozilla.org/en-US/contribute/studentambassadors/", | ||
"subscribed": False, | ||
"unsub_reason": "Graduated, don't have time for FSA", | ||
"create_timestamp": "2010-01-01T08:04:00+00:00", | ||
"update_timestamp": "2020-01-28T14:50:00+00:00", | ||
}, | ||
{ | ||
"format": "T", | ||
"lang": "fr", | ||
"name": "common-voice", | ||
"source": "https://commonvoice.mozilla.org/fr", | ||
"subscribed": True, | ||
"unsub_reason": None, | ||
"create_timestamp": "2010-01-01T08:04:00+00:00", | ||
"update_timestamp": "2020-01-28T14:50:00+00:00", | ||
}, | ||
{ | ||
"format": "H", | ||
"lang": "fr", | ||
"name": "firefox-accounts-journey", | ||
"source": "https://www.mozilla.org/fr/firefox/accounts/", | ||
"subscribed": False, | ||
"unsub_reason": "done with this mailing list", | ||
"create_timestamp": "2010-01-01T08:04:00+00:00", | ||
"update_timestamp": "2020-01-28T14:50:00+00:00", | ||
}, | ||
{ | ||
"format": "H", | ||
"lang": "en", | ||
"name": "firefox-os", | ||
"source": None, | ||
"subscribed": True, | ||
"unsub_reason": None, | ||
"create_timestamp": "2010-01-01T08:04:00+00:00", | ||
"update_timestamp": "2020-01-28T14:50:00+00:00", | ||
}, | ||
{ | ||
"format": "H", | ||
"lang": "fr", | ||
"name": "hubs", | ||
"source": None, | ||
"subscribed": True, | ||
"unsub_reason": None, | ||
"create_timestamp": "2010-01-01T08:04:00+00:00", | ||
"update_timestamp": "2020-01-28T14:50:00+00:00", | ||
}, | ||
{ | ||
"format": "H", | ||
"lang": "en", | ||
"name": "mozilla-festival", | ||
"source": None, | ||
"subscribed": True, | ||
"unsub_reason": None, | ||
"create_timestamp": "2010-01-01T08:04:00+00:00", | ||
"update_timestamp": "2020-01-28T14:50:00+00:00", | ||
}, | ||
{ | ||
"format": "H", | ||
"lang": "fr", | ||
"name": "mozilla-foundation", | ||
"source": None, | ||
"subscribed": True, | ||
"unsub_reason": None, | ||
"create_timestamp": "2010-01-01T08:04:00+00:00", | ||
"update_timestamp": "2020-01-28T14:50:00+00:00", | ||
}, | ||
], | ||
"status": "ok", | ||
"vpn_waitlist": {"geo": "ca", "platform": "windows,android"}, | ||
"relay_waitlist": {"geo": "cn"}, | ||
"waitlists": [ | ||
{ | ||
"fields": {"geo": "fr"}, | ||
"name": "a-software", | ||
"source": "https://a-software.mozilla.org/", | ||
"subscribed": True, | ||
"unsub_reason": None, | ||
"create_timestamp": "2010-01-01T08:04:00+00:00", | ||
"update_timestamp": "2020-01-28T14:50:00+00:00", | ||
}, | ||
{ | ||
"fields": {"geo": "cn"}, | ||
"name": "relay", | ||
"source": None, | ||
"subscribed": True, | ||
"unsub_reason": None, | ||
"create_timestamp": "2010-01-01T08:04:00+00:00", | ||
"update_timestamp": "2020-01-28T14:50:00+00:00", | ||
}, | ||
{ | ||
"fields": {"geo": "fr", "platform": "win64"}, | ||
"name": "super-product", | ||
"source": "https://super-product.mozilla.org/", | ||
"subscribed": True, | ||
"unsub_reason": None, | ||
"create_timestamp": "2010-01-01T08:04:00+00:00", | ||
"update_timestamp": "2020-01-28T14:50:00+00:00", | ||
}, | ||
{ | ||
"fields": {"geo": "ca", "platform": "windows,android"}, | ||
"name": "vpn", | ||
"source": None, | ||
"subscribed": True, | ||
"unsub_reason": None, | ||
"create_timestamp": "2010-01-01T08:04:00+00:00", | ||
"update_timestamp": "2020-01-28T14:50:00+00:00", | ||
}, | ||
], | ||
} | ||
|
||
|
||
def test_get_ctms_for_api_example(client, example_contact): | ||
"""The API examples represent a valid contact with many fields set. | ||
Test that the API examples are valid.""" | ||
|
Oops, something went wrong.