mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-23 00:41:35 -05:00
Change the ServiceEmailReplyTo model to uselist for the backref to services (allow 0 to many reply to emails)
Add another assert in the test
This commit is contained in:
@@ -1337,7 +1337,7 @@ class ServiceEmailReplyTo(db.Model):
|
||||
id = db.Column(UUID(as_uuid=True), primary_key=True, default=uuid.uuid4)
|
||||
|
||||
service_id = db.Column(UUID(as_uuid=True), db.ForeignKey('services.id'), unique=False, index=True, nullable=False)
|
||||
service = db.relationship(Service, backref=db.backref("reply_to_email_addresses", uselist=False))
|
||||
service = db.relationship(Service, backref=db.backref("reply_to_email_addresses"))
|
||||
|
||||
email_address = db.Column(db.Text, nullable=False, index=False, unique=False)
|
||||
is_default = db.Column(db.Boolean, nullable=False, default=True)
|
||||
|
||||
@@ -2126,7 +2126,7 @@ def test_is_service_name_unique_returns_400_when_name_does_not_exist(client):
|
||||
|
||||
|
||||
def test_update_service_reply_to_email_address_upserts_email_reply_to(admin_request, sample_service):
|
||||
admin_request.post(
|
||||
response = admin_request.post(
|
||||
'service.update_service',
|
||||
service_id=sample_service.id,
|
||||
_data={
|
||||
@@ -2135,4 +2135,8 @@ def test_update_service_reply_to_email_address_upserts_email_reply_to(admin_requ
|
||||
_expected_status=200
|
||||
)
|
||||
|
||||
assert len(ServiceEmailReplyTo.query.all()) == 1
|
||||
service_reply_to_emails = ServiceEmailReplyTo.query.all()
|
||||
assert len(service_reply_to_emails) == 1
|
||||
assert service_reply_to_emails[0].email_address == 'new@mail.com'
|
||||
assert service_reply_to_emails[0].is_default
|
||||
assert response['data']['reply_to_email_address'] == 'new@mail.com'
|
||||
|
||||
Reference in New Issue
Block a user