Skip to content

Commit

Permalink
expand user_consent tests to check for withdrawn email mask
Browse files Browse the repository at this point in the history
  • Loading branch information
pbugni committed Mar 26, 2024
1 parent e3dce13 commit dafca0b
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions tests/test_consent.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from portal.models.audit import Audit
from portal.models.organization import Organization
from portal.models.research_study import ResearchStudy
from portal.models.user import User, WITHDRAWN_PREFIX
from portal.models.user_consent import UserConsent
from tests import TEST_USER_ID, TestCase

Expand Down Expand Up @@ -377,6 +378,10 @@ def test_delete_user_consent(self):
user_id=TEST_USER_ID, organization_id=org1_id).first()
assert dc.status == 'deleted'

# confirm withdrawn user email mask not in place
self.test_user = db.session.query(User).get(TEST_USER_ID)
assert not self.test_user._email.startswith(WITHDRAWN_PREFIX)

def test_withdraw_user_consent(self):
self.shallow_org_tree()
org = Organization.query.filter(Organization.id > 0).first()
Expand Down Expand Up @@ -421,6 +426,10 @@ def test_withdraw_user_consent(self):
assert not new_consent.send_reminders
assert new_consent.acceptance_date == suspend_date

# confirm withdrawn user email mask in place
self.test_user = db.session.query(User).get(TEST_USER_ID)
assert self.test_user._email.startswith(WITHDRAWN_PREFIX)

def test_withdraw_user_consent_other_study(self):
self.shallow_org_tree()
org = Organization.query.filter(Organization.id > 0).first()
Expand Down Expand Up @@ -491,6 +500,10 @@ def test_withdraw_user_consent_other_study(self):
assert valid_consents[1].research_study_id == 1
assert valid_consents[1].acceptance_date == study_1_acceptance_date

# confirm user email isn't masked
self.test_user = db.session.query(User).get(TEST_USER_ID)
assert not self.test_user._email.startswith(WITHDRAWN_PREFIX)

def test_withdraw_too_early(self):
"""Avoid problems with withdrawals predating the existing consent"""
self.shallow_org_tree()
Expand Down Expand Up @@ -587,3 +600,7 @@ def test_double_withdrawal(self):
status='suspended')
assert query.count() == 1
assert query.first().acceptance_date == just_right

# confirm withdrawn user email mask in place
self.test_user = db.session.query(User).get(TEST_USER_ID)
assert self.test_user._email.startswith(WITHDRAWN_PREFIX)

0 comments on commit dafca0b

Please sign in to comment.