mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-23 17:01:35 -05:00
Use Notifications.query.one(), rather than assert count is 1 and query for all and get first item in list.
40 lines
1.1 KiB
Python
40 lines
1.1 KiB
Python
import uuid
|
|
from datetime import datetime
|
|
|
|
import pytest
|
|
|
|
from app import DATETIME_FORMAT
|
|
from app.models import (
|
|
Notification,
|
|
ServiceWhitelist,
|
|
MOBILE_TYPE, EMAIL_TYPE)
|
|
|
|
|
|
@pytest.mark.parametrize('mobile_number', [
|
|
'07700 900678',
|
|
'+44 7700 900678'
|
|
])
|
|
def test_should_build_service_whitelist_from_mobile_number(mobile_number):
|
|
service_whitelist = ServiceWhitelist.from_string('service_id', MOBILE_TYPE, mobile_number)
|
|
|
|
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_TYPE, email_address)
|
|
|
|
assert service_whitelist.recipient == email_address
|
|
|
|
|
|
@pytest.mark.parametrize('contact, recipient_type', [
|
|
('', None),
|
|
('07700dsadsad', MOBILE_TYPE),
|
|
('gmail.com', EMAIL_TYPE)
|
|
])
|
|
def test_should_not_build_service_whitelist_from_invalid_contact(recipient_type, contact):
|
|
with pytest.raises(ValueError):
|
|
ServiceWhitelist.from_string('service_id', recipient_type, contact)
|