mirror of
https://github.com/GSA/notifications-api.git
synced 2026-09-10 10:03:38 -04:00
Rename JSONModel to SerialisedModel 2/2
This class doesn’t actually wrap JSON, it wraps serialised data. So this name feels better.
This commit is contained in:
@@ -21,7 +21,7 @@ from app.notifications.process_notifications import create_content_for_notificat
|
|||||||
from app.utils import get_public_notify_type_text
|
from app.utils import get_public_notify_type_text
|
||||||
from app.dao.service_email_reply_to_dao import dao_get_reply_to_by_id
|
from app.dao.service_email_reply_to_dao import dao_get_reply_to_by_id
|
||||||
from app.dao.service_letter_contact_dao import dao_get_letter_contact_by_id
|
from app.dao.service_letter_contact_dao import dao_get_letter_contact_by_id
|
||||||
from app.serialised_models import TemplateJSONModel
|
from app.serialised_models import SerialisedTemplate
|
||||||
|
|
||||||
from gds_metrics.metrics import Histogram
|
from gds_metrics.metrics import Histogram
|
||||||
|
|
||||||
@@ -164,7 +164,7 @@ def get_template_dict(template_id, service_id):
|
|||||||
|
|
||||||
|
|
||||||
def get_template_model(template_id, service_id):
|
def get_template_model(template_id, service_id):
|
||||||
return TemplateJSONModel(get_template_dict(template_id, service_id))
|
return SerialisedTemplate(get_template_dict(template_id, service_id))
|
||||||
|
|
||||||
|
|
||||||
def validate_template(template_id, personalisation, service, notification_type):
|
def validate_template(template_id, personalisation, service, notification_type):
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
from abc import ABC, abstractmethod
|
from abc import ABC, abstractmethod
|
||||||
|
|
||||||
|
|
||||||
class JSONModel(ABC):
|
class SerialisedModel(ABC):
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
@@ -16,7 +16,7 @@ class JSONModel(ABC):
|
|||||||
return super().__dir__() + list(sorted(self.ALLOWED_PROPERTIES))
|
return super().__dir__() + list(sorted(self.ALLOWED_PROPERTIES))
|
||||||
|
|
||||||
|
|
||||||
class TemplateJSONModel(JSONModel):
|
class SerialisedTemplate(SerialisedModel):
|
||||||
ALLOWED_PROPERTIES = {
|
ALLOWED_PROPERTIES = {
|
||||||
'archived',
|
'archived',
|
||||||
'content',
|
'content',
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ from app.models import Notification
|
|||||||
from app.models import NOTIFICATION_CREATED
|
from app.models import NOTIFICATION_CREATED
|
||||||
from app.notifications.process_letter_notifications import create_letter_notification
|
from app.notifications.process_letter_notifications import create_letter_notification
|
||||||
from app.notifications.validators import get_template_dict
|
from app.notifications.validators import get_template_dict
|
||||||
from app.json_models import TemplateJSONModel
|
from app.serialised_models import SerialisedTemplate
|
||||||
|
|
||||||
|
|
||||||
def test_create_letter_notification_creates_notification(sample_letter_template, sample_api_key):
|
def test_create_letter_notification_creates_notification(sample_letter_template, sample_api_key):
|
||||||
@@ -15,7 +15,7 @@ def test_create_letter_notification_creates_notification(sample_letter_template,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template = TemplateJSONModel(get_template_dict(
|
template = SerialisedTemplate(get_template_dict(
|
||||||
sample_letter_template.id, sample_letter_template.service_id
|
sample_letter_template.id, sample_letter_template.service_id
|
||||||
))
|
))
|
||||||
|
|
||||||
@@ -50,7 +50,7 @@ def test_create_letter_notification_sets_reference(sample_letter_template, sampl
|
|||||||
'reference': 'foo'
|
'reference': 'foo'
|
||||||
}
|
}
|
||||||
|
|
||||||
template = TemplateJSONModel(get_template_dict(
|
template = SerialisedTemplate(get_template_dict(
|
||||||
sample_letter_template.id, sample_letter_template.service_id
|
sample_letter_template.id, sample_letter_template.service_id
|
||||||
))
|
))
|
||||||
|
|
||||||
@@ -74,7 +74,7 @@ def test_create_letter_notification_sets_billable_units(sample_letter_template,
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
template = TemplateJSONModel(get_template_dict(
|
template = SerialisedTemplate(get_template_dict(
|
||||||
sample_letter_template.id, sample_letter_template.service_id
|
sample_letter_template.id, sample_letter_template.service_id
|
||||||
))
|
))
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user