mirror of
https://github.com/GSA/notifications-api.git
synced 2026-01-31 23:26:23 -05:00
Update ServiceWhitelist to conform to new data model
This commit is contained in:
@@ -3,7 +3,10 @@ from datetime import datetime
|
||||
import pytest
|
||||
|
||||
from app import DATETIME_FORMAT
|
||||
from app.models import Notification, ServiceWhitelist
|
||||
from app.models import (
|
||||
Notification,
|
||||
ServiceWhitelist,
|
||||
MOBILE_TYPE, EMAIL_TYPE)
|
||||
|
||||
|
||||
def test_should_build_notification_from_minimal_set_of_api_derived_params(notify_api):
|
||||
@@ -79,27 +82,25 @@ def test_should_build_notification_from_full_set_of_api_derived_params(notify_ap
|
||||
'+44 7700 900678'
|
||||
])
|
||||
def test_should_build_service_whitelist_from_mobile_number(mobile_number):
|
||||
service_whitelist = ServiceWhitelist.from_string('service_id', mobile_number)
|
||||
service_whitelist = ServiceWhitelist.from_string('service_id', MOBILE_TYPE, mobile_number)
|
||||
|
||||
assert service_whitelist.mobile_number == mobile_number
|
||||
assert service_whitelist.email_address is None
|
||||
assert service_whitelist.recipient == mobile_number
|
||||
|
||||
|
||||
@pytest.mark.parametrize('email_address', [
|
||||
'test@example.com'
|
||||
])
|
||||
def test_should_build_service_whitelist_from_email_address(email_address):
|
||||
service_whitelist = ServiceWhitelist.from_string('service_id', email_address)
|
||||
service_whitelist = ServiceWhitelist.from_string('service_id', EMAIL_TYPE, email_address)
|
||||
|
||||
assert service_whitelist.email_address == email_address
|
||||
assert service_whitelist.mobile_number is None
|
||||
assert service_whitelist.recipient == email_address
|
||||
|
||||
|
||||
@pytest.mark.parametrize('contact', [
|
||||
'',
|
||||
'07700dsadsad',
|
||||
'gmail.com'
|
||||
@pytest.mark.parametrize('contact, recipient_type', [
|
||||
('', None),
|
||||
('07700dsadsad', MOBILE_TYPE),
|
||||
('gmail.com', EMAIL_TYPE)
|
||||
])
|
||||
def test_should_not_build_service_whitelist_from_invalid_contact(contact):
|
||||
def test_should_not_build_service_whitelist_from_invalid_contact(recipient_type, contact):
|
||||
with pytest.raises(ValueError):
|
||||
ServiceWhitelist.from_string('service_id', contact)
|
||||
ServiceWhitelist.from_string('service_id', recipient_type, contact)
|
||||
|
||||
Reference in New Issue
Block a user