fix purge functional test data task

* it doesn't delete service email reply to or letter contacts, or
  contact lists. I don't think the contact lists will ever be an issue
  but it doesn't hurt to add it to the list of things to remove.
* it doesn't remove users from organisations before deleting the users

there may be more tables that link to Service that should be deleted,
but for now just add these ones that I could spot.
This commit is contained in:
Leo Hemsted
2020-03-30 17:42:59 +01:00
parent c1ba3fb1be
commit 885f3122bd
3 changed files with 17 additions and 5 deletions

View File

@@ -663,13 +663,15 @@ def test_create_service_and_history_is_transactional(notify_db_session):
def test_delete_service_and_associated_objects(notify_db_session):
user = create_user()
service = create_service(user=user, service_permissions=None)
organisation = create_organisation()
service = create_service(user=user, service_permissions=None, organisation=organisation)
create_user_code(user=user, code='somecode', code_type='email')
create_user_code(user=user, code='somecode', code_type='sms')
template = create_template(service=service)
api_key = create_api_key(service=service)
create_notification(template=template, api_key=api_key)
create_invited_user(service=service)
user.organisations = [organisation]
assert ServicePermission.query.count() == len((
SMS_TYPE, EMAIL_TYPE, LETTER_TYPE, INTERNATIONAL_SMS_TYPE, UPLOAD_LETTERS,
@@ -689,6 +691,8 @@ def test_delete_service_and_associated_objects(notify_db_session):
assert Service.query.count() == 0
assert Service.get_history_model().query.count() == 0
assert ServicePermission.query.count() == 0
# the organisation hasn't been deleted
assert Organisation.query.count() == 1
def test_add_existing_user_to_another_service_doesnot_change_old_permissions(notify_db_session):