-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #132 from SexualHealthInnovations/multiple-report-…
…recipients allow reports to be sent to multiple recipients
- Loading branch information
Showing
5 changed files
with
69 additions
and
4 deletions.
There are no files selected for viewing
20 changes: 20 additions & 0 deletions
20
callisto/delivery/migrations/0009_to_address_to_textfield.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# -*- coding: utf-8 -*- | ||
# Generated by Django 1.10.5 on 2017-01-24 15:20 | ||
from __future__ import unicode_literals | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('delivery', '0008_make_salt_nullable'), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name='sentreport', | ||
name='to_address', | ||
field=models.CharField(max_length=4096), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -92,3 +92,28 @@ def test_matches_after_encryption(self, mock_process): | |
find_matches([identifier]) | ||
# have to use ANY because objects in migration tests are faked | ||
mock_process.assert_called_once_with([ANY, ANY], 'test_identifier', PDFMatchReport) | ||
|
||
|
||
class MultipleRecipientMigrationTest(MigrationTest): | ||
|
||
app_name = 'delivery' | ||
before = '0008_make_salt_nullable' | ||
after = '0009_to_address_to_textfield' | ||
|
||
def test_recipient_data_is_migrated(self): | ||
|
||
user = User.objects.create_user(username="dummy", password="dummy") | ||
Report = self.get_model_before('Report') | ||
report = Report(owner_id=user.pk) | ||
report.save() | ||
SentFullReport = self.get_model_before('SentFullReport') | ||
sent_report = SentFullReport.objects.create(report_id=report.pk, to_address="[email protected]") | ||
sent_report.save() | ||
self.assertEqual(SentFullReport.objects.count(), 1) | ||
|
||
self.run_migration() | ||
|
||
SentFullReport = self.get_model_after('SentFullReport') | ||
self.assertEqual(SentFullReport.objects.count(), 1) | ||
sent_report = SentFullReport.objects.first() | ||
self.assertEqual(sent_report.to_address, '[email protected]') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,7 +16,9 @@ | |
from django.test.utils import override_settings | ||
|
||
from callisto.delivery.forms import NewSecretKeyForm, SecretKeyForm | ||
from callisto.delivery.models import EmailNotification, MatchReport, Report | ||
from callisto.delivery.models import ( | ||
EmailNotification, MatchReport, Report, SentFullReport, | ||
) | ||
from callisto.evaluation.models import EvalRow | ||
|
||
from .forms import EncryptedFormWizard | ||
|
@@ -475,6 +477,24 @@ def test_submit_sends_report(self): | |
self.assertEqual(message.to, ['[email protected]']) | ||
self.assertRegexpMatches(message.attachments[0][0], 'report_.*\\.pdf\\.gpg') | ||
|
||
@override_settings(COORDINATOR_EMAIL='[email protected],[email protected]') | ||
def test_submit_sends_report_to_multiple_coordinators(self): | ||
response = self.client.post((self.submission_url % self.report.pk), | ||
data={'name': 'test submitter', | ||
'email': '[email protected]', | ||
'phone_number': '555-555-1212', | ||
'email_confirmation': "False", | ||
'key': self.report_key}) | ||
self.assertEqual(response.status_code, 200) | ||
self.assertNotIn('submit_error', response.context) | ||
self.assertEqual(len(mail.outbox), 1) | ||
self.assertEqual(SentFullReport.objects.count(), 1) | ||
message1 = mail.outbox[0] | ||
self.assertEqual(message1.subject, 'test delivery') | ||
self.assertIn('"Reports" <reports', message1.from_email) | ||
self.assertEqual(message1.to, ['[email protected]', '[email protected]']) | ||
self.assertRegexpMatches(message1.attachments[0][0], 'report_.*\\.pdf\\.gpg') | ||
|
||
def test_submit_sends_email_confirmation(self): | ||
response = self.client.post((self.submission_url % self.report.pk), | ||
data={'name': 'test submitter', | ||
|