mirror of
https://github.com/GSA/notifications-api.git
synced 2026-08-16 20:48:37 -04:00
@@ -1,6 +1,7 @@
|
|||||||
from strenum import StrEnum # In 3.11 this is in the enum library. We will not need
|
from strenum import StrEnum # type: ignore [import-not-found]
|
||||||
|
# In 3.11 this is in the enum library. We will not need this external library any more.
|
||||||
# this external library any more.
|
# The line will simply change from importing from strenum to importing from enum.
|
||||||
|
# And the strenum library can then be removed from poetry.
|
||||||
|
|
||||||
|
|
||||||
class TemplateType(StrEnum):
|
class TemplateType(StrEnum):
|
||||||
|
|||||||
@@ -1164,8 +1164,10 @@ class TemplateBase(db.Model):
|
|||||||
def _as_utils_template(self):
|
def _as_utils_template(self):
|
||||||
if self.template_type == TemplateType.EMAIL:
|
if self.template_type == TemplateType.EMAIL:
|
||||||
return PlainTextEmailTemplate(self.__dict__)
|
return PlainTextEmailTemplate(self.__dict__)
|
||||||
if self.template_type == TemplateType.SMS:
|
elif self.template_type == TemplateType.SMS:
|
||||||
return SMSMessageTemplate(self.__dict__)
|
return SMSMessageTemplate(self.__dict__)
|
||||||
|
else:
|
||||||
|
raise ValueError(f"{self.template_type} is an invalid template type.")
|
||||||
|
|
||||||
def _as_utils_template_with_personalisation(self, values):
|
def _as_utils_template_with_personalisation(self, values):
|
||||||
template = self._as_utils_template()
|
template = self._as_utils_template()
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ def test_get_all_templates_returns_200(client, sample_service):
|
|||||||
subject=f"subject_{name}" if tmp_type == TemplateType.EMAIL else "",
|
subject=f"subject_{name}" if tmp_type == TemplateType.EMAIL else "",
|
||||||
template_name=name,
|
template_name=name,
|
||||||
)
|
)
|
||||||
for name, tmp_type in product(("A", "B", "C"), TemplateType)
|
for name, tmp_type in (("A", TemplateType.SMS), ("B", TemplateType.EMAIL))
|
||||||
]
|
]
|
||||||
|
|
||||||
auth_header = create_service_authorization_header(service_id=sample_service.id)
|
auth_header = create_service_authorization_header(service_id=sample_service.id)
|
||||||
@@ -41,7 +41,7 @@ def test_get_all_templates_returns_200(client, sample_service):
|
|||||||
assert template["subject"] == templates[index].subject
|
assert template["subject"] == templates[index].subject
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize("tmp_type", TemplateType)
|
@pytest.mark.parametrize("tmp_type", (TemplateType.SMS, TemplateType.EMAIL))
|
||||||
def test_get_all_templates_for_valid_type_returns_200(client, sample_service, tmp_type):
|
def test_get_all_templates_for_valid_type_returns_200(client, sample_service, tmp_type):
|
||||||
templates = [
|
templates = [
|
||||||
create_template(
|
create_template(
|
||||||
@@ -75,7 +75,7 @@ def test_get_all_templates_for_valid_type_returns_200(client, sample_service, tm
|
|||||||
assert template["subject"] == templates[index].subject
|
assert template["subject"] == templates[index].subject
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize("tmp_type", TemplateType)
|
@pytest.mark.parametrize("tmp_type", (TemplateType.SMS, TemplateType.EMAIL))
|
||||||
def test_get_correct_num_templates_for_valid_type_returns_200(
|
def test_get_correct_num_templates_for_valid_type_returns_200(
|
||||||
client, sample_service, tmp_type
|
client, sample_service, tmp_type
|
||||||
):
|
):
|
||||||
|
|||||||
Reference in New Issue
Block a user