Give new services the upload letters permission

This will switch on this feature for new services.

After this we will:
- give existing services this permission with a database migration
- remove this permission from the codebase entirely so that everyone has
  this feature and can’t switch it off
This commit is contained in:
Chris Hill-Scott
2020-02-25 13:56:39 +00:00
parent 42f02c8c24
commit b3c9680487
3 changed files with 12 additions and 9 deletions

View File

@@ -37,6 +37,7 @@ from app.dao.services_dao import (dao_add_user_to_service, dao_create_service,
from app.dao.users_dao import create_user_code, save_model_user
from app.models import (EMAIL_TYPE, INTERNATIONAL_SMS_TYPE, KEY_TYPE_NORMAL,
KEY_TYPE_TEAM, KEY_TYPE_TEST, LETTER_TYPE, SMS_TYPE,
UPLOAD_LETTERS,
ApiKey, InvitedUser, Job, Notification,
NotificationHistory, Organisation, Permission, Service,
ServicePermission, ServiceUser, Template,
@@ -488,16 +489,16 @@ def test_create_service_returns_service_with_default_permissions(notify_db_sessi
service = dao_fetch_service_by_id(service.id)
_assert_service_permissions(service.permissions, (
SMS_TYPE, EMAIL_TYPE, LETTER_TYPE, INTERNATIONAL_SMS_TYPE,
SMS_TYPE, EMAIL_TYPE, LETTER_TYPE, INTERNATIONAL_SMS_TYPE, UPLOAD_LETTERS
))
@pytest.mark.parametrize("permission_to_remove, permissions_remaining", [
(SMS_TYPE, (
EMAIL_TYPE, LETTER_TYPE, INTERNATIONAL_SMS_TYPE,
EMAIL_TYPE, LETTER_TYPE, INTERNATIONAL_SMS_TYPE, UPLOAD_LETTERS,
)),
(EMAIL_TYPE, (
SMS_TYPE, LETTER_TYPE, INTERNATIONAL_SMS_TYPE,
SMS_TYPE, LETTER_TYPE, INTERNATIONAL_SMS_TYPE, UPLOAD_LETTERS,
)),
])
def test_remove_permission_from_service_by_id_returns_service_with_correct_permissions(
@@ -529,14 +530,14 @@ def test_create_service_by_id_adding_and_removing_letter_returns_service_without
service = dao_fetch_service_by_id(service.id)
_assert_service_permissions(service.permissions, (
SMS_TYPE, EMAIL_TYPE, LETTER_TYPE, INTERNATIONAL_SMS_TYPE,
SMS_TYPE, EMAIL_TYPE, LETTER_TYPE, INTERNATIONAL_SMS_TYPE, UPLOAD_LETTERS,
))
dao_remove_service_permission(service_id=service.id, permission=LETTER_TYPE)
service = dao_fetch_service_by_id(service.id)
_assert_service_permissions(service.permissions, (
SMS_TYPE, EMAIL_TYPE, INTERNATIONAL_SMS_TYPE,
SMS_TYPE, EMAIL_TYPE, INTERNATIONAL_SMS_TYPE, UPLOAD_LETTERS,
))
@@ -671,7 +672,7 @@ def test_delete_service_and_associated_objects(notify_db_session):
create_invited_user(service=service)
assert ServicePermission.query.count() == len((
SMS_TYPE, EMAIL_TYPE, LETTER_TYPE, INTERNATIONAL_SMS_TYPE,
SMS_TYPE, EMAIL_TYPE, LETTER_TYPE, INTERNATIONAL_SMS_TYPE, UPLOAD_LETTERS,
))
delete_service_and_all_associated_db_objects(service)