mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-25 01:41:34 -05:00
Update ServiceWhitelist dao to conform to new data model
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
from app import db
|
||||
from app.models import ServiceWhitelist
|
||||
from app.models import Service, ServiceWhitelist
|
||||
|
||||
|
||||
def dao_fetch_service_whitelist(service_id):
|
||||
return ServiceWhitelist.query.filter(ServiceWhitelist.service_id == service_id).all()
|
||||
return ServiceWhitelist.query.filter(
|
||||
ServiceWhitelist.service_id == service_id).all()
|
||||
|
||||
|
||||
def dao_add_and_commit_whitelisted_contacts(objs):
|
||||
@@ -12,4 +13,5 @@ def dao_add_and_commit_whitelisted_contacts(objs):
|
||||
|
||||
|
||||
def dao_remove_service_whitelist(service_id):
|
||||
return ServiceWhitelist.query.filter(ServiceWhitelist.service_id == service_id).delete()
|
||||
return ServiceWhitelist.query.filter(
|
||||
ServiceWhitelist.service_id == service_id).delete()
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
import uuid
|
||||
|
||||
from app.models import ServiceWhitelist
|
||||
from app.models import (
|
||||
ServiceWhitelist,
|
||||
MOBILE_TYPE, EMAIL_TYPE)
|
||||
|
||||
from app.dao.service_whitelist_dao import (
|
||||
dao_fetch_service_whitelist,
|
||||
dao_add_and_commit_whitelisted_contacts,
|
||||
@@ -21,7 +24,7 @@ def test_fetch_service_whitelist_ignores_other_service(sample_service_whitelist)
|
||||
|
||||
|
||||
def test_add_and_commit_whitelisted_contacts_saves_data(sample_service):
|
||||
whitelist = ServiceWhitelist.from_string(sample_service.id, 'foo@example.com')
|
||||
whitelist = ServiceWhitelist.from_string(sample_service.id, EMAIL_TYPE, 'foo@example.com')
|
||||
|
||||
dao_add_and_commit_whitelisted_contacts([whitelist])
|
||||
|
||||
@@ -34,8 +37,8 @@ def test_remove_service_whitelist_only_removes_for_my_service(notify_db, notify_
|
||||
service_1 = create_service(notify_db, notify_db_session, service_name="service 1")
|
||||
service_2 = create_service(notify_db, notify_db_session, service_name="service 2")
|
||||
dao_add_and_commit_whitelisted_contacts([
|
||||
ServiceWhitelist.from_string(service_1.id, 'service1@example.com'),
|
||||
ServiceWhitelist.from_string(service_2.id, 'service2@example.com')
|
||||
ServiceWhitelist.from_string(service_1.id, EMAIL_TYPE, 'service1@example.com'),
|
||||
ServiceWhitelist.from_string(service_2.id, EMAIL_TYPE, 'service2@example.com')
|
||||
])
|
||||
|
||||
dao_remove_service_whitelist(service_1.id)
|
||||
|
||||
Reference in New Issue
Block a user