mirror of
https://github.com/GSA/notifications-api.git
synced 2026-09-11 18:38:14 -04:00
Add test function to create service whitelist
This will be used to stop us needing to call the `sample_service_whitelist` fixture as a function.
This commit is contained in:
+16
-1
@@ -42,9 +42,11 @@ from app.models import (
|
|||||||
ScheduledNotification,
|
ScheduledNotification,
|
||||||
ServicePermission,
|
ServicePermission,
|
||||||
ServiceSmsSender,
|
ServiceSmsSender,
|
||||||
|
ServiceWhitelist,
|
||||||
Template,
|
Template,
|
||||||
User,
|
User,
|
||||||
EMAIL_TYPE,
|
EMAIL_TYPE,
|
||||||
|
MOBILE_TYPE,
|
||||||
SMS_TYPE,
|
SMS_TYPE,
|
||||||
LETTER_TYPE,
|
LETTER_TYPE,
|
||||||
KEY_TYPE_NORMAL,
|
KEY_TYPE_NORMAL,
|
||||||
@@ -89,7 +91,7 @@ def create_permissions(user, service, *permissions):
|
|||||||
for p in permissions
|
for p in permissions
|
||||||
]
|
]
|
||||||
|
|
||||||
permission_dao.set_user_service_permission(user, service, permissions)
|
permission_dao.set_user_service_permission(user, service, permissions, _commit=True)
|
||||||
|
|
||||||
|
|
||||||
def create_service(
|
def create_service(
|
||||||
@@ -738,6 +740,19 @@ def create_ft_notification_status(
|
|||||||
return data
|
return data
|
||||||
|
|
||||||
|
|
||||||
|
def create_service_whitelist(service, email_address=None, mobile_number=None):
|
||||||
|
if email_address:
|
||||||
|
whitelisted_user = ServiceWhitelist.from_string(service.id, EMAIL_TYPE, email_address)
|
||||||
|
elif mobile_number:
|
||||||
|
whitelisted_user = ServiceWhitelist.from_string(service.id, MOBILE_TYPE, mobile_number)
|
||||||
|
else:
|
||||||
|
whitelisted_user = ServiceWhitelist.from_string(service.id, EMAIL_TYPE, 'whitelisted_user@digital.gov.uk')
|
||||||
|
|
||||||
|
db.session.add(whitelisted_user)
|
||||||
|
db.session.commit()
|
||||||
|
return whitelisted_user
|
||||||
|
|
||||||
|
|
||||||
def create_complaint(service=None,
|
def create_complaint(service=None,
|
||||||
notification=None,
|
notification=None,
|
||||||
created_at=None):
|
created_at=None):
|
||||||
|
|||||||
Reference in New Issue
Block a user