mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-01 07:35:34 -05:00
create, edit and use email branding instead of organisation
notable things that have been kept until migration is complete: * passing in `organisation` to update_service will update email branding * both `/email-branding` and `/organisation` hit the same code * service endpoints still return organisation as well as email branding
This commit is contained in:
44
tests/app/dao/test_email_branding_dao.py
Normal file
44
tests/app/dao/test_email_branding_dao.py
Normal file
@@ -0,0 +1,44 @@
|
||||
from app.dao.email_branding_dao import (
|
||||
dao_get_email_branding_options,
|
||||
dao_get_email_branding_by_id,
|
||||
dao_update_email_branding,
|
||||
)
|
||||
from app.models import EmailBranding
|
||||
|
||||
from tests.app.db import create_email_branding
|
||||
|
||||
|
||||
def test_get_email_branding_options_gets_all_email_branding(notify_db, notify_db_session):
|
||||
email_branding_1 = create_email_branding(name='test_email_branding_1')
|
||||
email_branding_2 = create_email_branding(name='test_email_branding_2')
|
||||
|
||||
email_branding = dao_get_email_branding_options()
|
||||
|
||||
assert len(email_branding) == 2
|
||||
assert email_branding_1 == email_branding[0]
|
||||
assert email_branding_2 == email_branding[1]
|
||||
|
||||
|
||||
def test_get_email_branding_by_id_gets_correct_email_branding(notify_db, notify_db_session):
|
||||
email_branding = create_email_branding()
|
||||
|
||||
email_branding_from_db = dao_get_email_branding_by_id(email_branding.id)
|
||||
|
||||
assert email_branding_from_db == email_branding
|
||||
|
||||
|
||||
def test_update_email_branding(notify_db, notify_db_session):
|
||||
updated_name = 'new name'
|
||||
create_email_branding()
|
||||
|
||||
email_branding = EmailBranding.query.all()
|
||||
|
||||
assert len(email_branding) == 1
|
||||
assert email_branding[0].name != updated_name
|
||||
|
||||
dao_update_email_branding(email_branding[0], name=updated_name)
|
||||
|
||||
email_branding = EmailBranding.query.all()
|
||||
|
||||
assert len(email_branding) == 1
|
||||
assert email_branding[0].name == updated_name
|
||||
@@ -1,60 +0,0 @@
|
||||
from app.dao.organisations_dao import (
|
||||
dao_get_organisations,
|
||||
dao_get_organisation_by_id,
|
||||
dao_update_organisation,
|
||||
)
|
||||
from app.models import Organisation
|
||||
|
||||
from tests.app.db import create_organisation
|
||||
|
||||
|
||||
def test_create_organisation(notify_db, notify_db_session):
|
||||
organisation = create_organisation()
|
||||
|
||||
assert Organisation.query.count() == 1
|
||||
organisation_from_db = Organisation.query.first()
|
||||
assert organisation == organisation_from_db
|
||||
|
||||
|
||||
def test_create_organisation_without_name_or_colour_is_valid(notify_db, notify_db_session):
|
||||
organisation = create_organisation(logo=None, name=None, colour=None)
|
||||
|
||||
assert Organisation.query.count() == 1
|
||||
organisation_from_db = Organisation.query.first()
|
||||
assert organisation == organisation_from_db
|
||||
|
||||
|
||||
def test_get_organisations_gets_all_organisations(notify_db, notify_db_session):
|
||||
org_1 = create_organisation(name='test_org_1')
|
||||
org_2 = create_organisation(name='test_org_2')
|
||||
|
||||
organisations = dao_get_organisations()
|
||||
|
||||
assert len(organisations) == 2
|
||||
assert org_1 == organisations[0]
|
||||
assert org_2 == organisations[1]
|
||||
|
||||
|
||||
def test_get_organisation_by_id_gets_correct_organisation(notify_db, notify_db_session):
|
||||
organisation = create_organisation()
|
||||
|
||||
organisation_from_db = dao_get_organisation_by_id(organisation.id)
|
||||
|
||||
assert organisation_from_db == organisation
|
||||
|
||||
|
||||
def test_update_organisation(notify_db, notify_db_session):
|
||||
updated_name = 'new name'
|
||||
create_organisation()
|
||||
|
||||
organisations_1 = Organisation.query.all()
|
||||
|
||||
assert len(organisations_1) == 1
|
||||
assert organisations_1[0].name != updated_name
|
||||
|
||||
dao_update_organisation(organisations_1[0], name=updated_name)
|
||||
|
||||
organisations_2 = Organisation.query.all()
|
||||
|
||||
assert len(organisations_2) == 1
|
||||
assert organisations_2[0].name == updated_name
|
||||
Reference in New Issue
Block a user