mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-19 14:09:20 -04:00
merge from main
This commit is contained in:
@@ -2190,152 +2190,6 @@ def mock_send_already_registered_email(mocker):
|
||||
return mocker.patch("app.user_api_client.send_already_registered_email")
|
||||
|
||||
|
||||
def create_email_brandings(
|
||||
number_of_brandings, non_standard_values=None, shuffle=False
|
||||
):
|
||||
brandings = [
|
||||
{
|
||||
"id": str(idx),
|
||||
"name": "org {}".format(idx),
|
||||
"text": "org {}".format(idx),
|
||||
"colour": None,
|
||||
"logo": "logo{}.png".format(idx),
|
||||
"brand_type": "org",
|
||||
}
|
||||
for idx in range(1, number_of_brandings + 1)
|
||||
]
|
||||
|
||||
for idx, row in enumerate(non_standard_values or {}):
|
||||
brandings[row["idx"]].update(non_standard_values[idx])
|
||||
|
||||
if shuffle:
|
||||
brandings.insert(3, brandings.pop(4))
|
||||
|
||||
return brandings
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
def mock_get_all_email_branding(mocker):
|
||||
def _get_all_email_branding(sort_key=None):
|
||||
non_standard_values = [
|
||||
{"idx": 1, "colour": "red"},
|
||||
{"idx": 2, "colour": "orange"},
|
||||
{"idx": 3, "text": None},
|
||||
{"idx": 4, "colour": "blue"},
|
||||
]
|
||||
shuffle = sort_key is None
|
||||
return create_email_brandings(
|
||||
5, non_standard_values=non_standard_values, shuffle=shuffle
|
||||
)
|
||||
|
||||
return mocker.patch(
|
||||
"app.notify_client.email_branding_client.email_branding_client.get_all_email_branding",
|
||||
side_effect=_get_all_email_branding,
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
def mock_no_email_branding(mocker):
|
||||
def _get_email_branding():
|
||||
return []
|
||||
|
||||
return mocker.patch(
|
||||
"app.email_branding_client.get_all_email_branding",
|
||||
side_effect=_get_email_branding,
|
||||
)
|
||||
|
||||
|
||||
def create_email_branding(id, non_standard_values=None):
|
||||
branding = {
|
||||
"logo": "example.png",
|
||||
"name": "Organization name",
|
||||
"text": "Organization text",
|
||||
"id": id,
|
||||
"colour": "#f00",
|
||||
"brand_type": "org",
|
||||
}
|
||||
|
||||
if non_standard_values:
|
||||
branding.update(non_standard_values)
|
||||
|
||||
return {"email_branding": branding}
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
def mock_get_email_branding(mocker, fake_uuid):
|
||||
def _get_email_branding(id):
|
||||
return create_email_branding(fake_uuid)
|
||||
|
||||
return mocker.patch(
|
||||
"app.email_branding_client.get_email_branding", side_effect=_get_email_branding
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
def mock_get_email_branding_with_govuk_brand_type(mocker, fake_uuid):
|
||||
def _get_email_branding(id):
|
||||
return create_email_branding(fake_uuid, {"brand_type": "govuk"})
|
||||
|
||||
return mocker.patch(
|
||||
"app.email_branding_client.get_email_branding", side_effect=_get_email_branding
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
def mock_get_email_branding_with_both_brand_type(mocker, fake_uuid):
|
||||
def _get_email_branding(id):
|
||||
return create_email_branding(fake_uuid, {"brand_type": "both"})
|
||||
|
||||
return mocker.patch(
|
||||
"app.email_branding_client.get_email_branding", side_effect=_get_email_branding
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
def mock_get_email_branding_with_org_banner_brand_type(mocker, fake_uuid):
|
||||
def _get_email_branding(id):
|
||||
return create_email_branding(fake_uuid, {"brand_type": "org_banner"})
|
||||
|
||||
return mocker.patch(
|
||||
"app.email_branding_client.get_email_branding", side_effect=_get_email_branding
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
def mock_get_email_branding_without_brand_text(mocker, fake_uuid):
|
||||
def _get_email_branding_without_brand_text(id):
|
||||
return create_email_branding(
|
||||
fake_uuid, {"text": "", "brand_type": "org_banner"}
|
||||
)
|
||||
|
||||
return mocker.patch(
|
||||
"app.email_branding_client.get_email_branding",
|
||||
side_effect=_get_email_branding_without_brand_text,
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
def mock_create_email_branding(mocker):
|
||||
def _create_email_branding(logo, name, text, colour, brand_type):
|
||||
return
|
||||
|
||||
return mocker.patch(
|
||||
"app.email_branding_client.create_email_branding",
|
||||
side_effect=_create_email_branding,
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
def mock_update_email_branding(mocker):
|
||||
def _update_email_branding(branding_id, logo, name, text, colour, brand_type):
|
||||
return
|
||||
|
||||
return mocker.patch(
|
||||
"app.email_branding_client.update_email_branding",
|
||||
side_effect=_update_email_branding,
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
def mock_get_guest_list(mocker):
|
||||
def _get_guest_list(service_id):
|
||||
|
||||
Reference in New Issue
Block a user