mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-01 07:35:34 -05:00
correct service_whitelist dao/rest functionality
additionally added dao tests
This commit is contained in:
25
tests/app/dao/test_service_whitelist_dao.py
Normal file
25
tests/app/dao/test_service_whitelist_dao.py
Normal file
@@ -0,0 +1,25 @@
|
||||
import uuid
|
||||
|
||||
from app.models import ServiceWhitelist
|
||||
from app.dao.service_whitelist_dao import (#
|
||||
dao_fetch_service_whitelist,
|
||||
dao_add_and_commit_whitelisted_contacts,
|
||||
dao_remove_service_whitelist
|
||||
)
|
||||
|
||||
|
||||
def test_fetch_service_whitelist_gets_whitelists(sample_service_whitelist):
|
||||
whitelist = dao_fetch_service_whitelist(sample_service_whitelist.service_id)
|
||||
assert len(whitelist) == 1
|
||||
assert whitelist[0].id == sample_service_whitelist.id
|
||||
|
||||
def test_fetch_service_whitelist_ignores_other_service(sample_service_whitelist):
|
||||
assert len(dao_fetch_service_whitelist(uuid.uuid4())) == 0
|
||||
|
||||
def test_add_and_commit_whitelisted_contacts_saves_data(sample_service):
|
||||
whitelist = ServiceWhitelist.from_string(sample_service.id, 'foo@example.com')
|
||||
dao_add_and_commit_whitelisted_contacts([whitelist])
|
||||
|
||||
db_contents = ServiceWhitelist.query.all()
|
||||
assert len(db_contents) == 1
|
||||
assert db_contents[0].id == whitelist.id
|
||||
Reference in New Issue
Block a user