示例#1
0
 def test_notifies_org_user_with_safe_data_diff(self, notification_patch):
     fresno_profile = app_reviewer('fresno_pubdef')
     santa_clara_profile = app_reviewer('santa_clara_pubdef')
     self.client.login(username=fresno_profile.user.username,
                       password=settings.TEST_USER_PASSWORD)
     response = self.client.get(self.edit_url)
     post_data = dict_to_post_data(
         response.context_data['form'].raw_input_data)
     post_data.update({
         'first_name': 'Foo',
         'last_name': 'Bar',
         'driver_license_or_id': '9123462907890387',
         'email': '*****@*****.**'
     })
     expected_safe_diff = {
         'First name': {
             'before': self.sub.first_name,
             'after': 'Foo'
         },
         'Last name': {
             'before': self.sub.last_name,
             'after': 'Bar'
         },
         'Email': {
             'before': self.sub.email,
             'after': '*****@*****.**'
         }
     }
     self.client.post(self.edit_url, post_data)
     notification_patch.send.assert_any_call(
         to=[santa_clara_profile.user.email],
         sender_profile=fresno_profile,
         editor_email=fresno_profile.user.email,
         editor_org_name=fresno_profile.organization.name,
         app_detail_url=self.sub.get_external_url(),
         submission_id=self.sub.id,
         applicant_name='Foo Bar',
         safe_data_diff=expected_safe_diff,
         unsafe_changed_keys=['Driver License/ID'])
     notification_patch.send.assert_any_call(
         to=[fresno_profile.user.email],
         sender_profile=fresno_profile,
         editor_email=fresno_profile.user.email,
         editor_org_name=fresno_profile.organization.name,
         app_detail_url=self.sub.get_external_url(),
         submission_id=self.sub.id,
         applicant_name='Foo Bar',
         safe_data_diff=expected_safe_diff,
         unsafe_changed_keys=['Driver License/ID'])
     self.assertEqual(2, len(notification_patch.send.mock_calls))
示例#2
0
    def test_org_user_gets_expected_form_for_their_org(self):
        fresno_profile = app_reviewer('fresno_pubdef')
        self.client.login(username=fresno_profile.user.username,
                          password=settings.TEST_USER_PASSWORD)
        response = self.client.get(self.edit_url)

        fresno_expected_fields = [
            F.ContactPreferences, F.FirstName, F.MiddleName, F.LastName,
            F.Aliases, F.PhoneNumberField, F.AlternatePhoneNumberField,
            F.AddressField, F.DriverLicenseOrIDNumber, F.EmailField,
            F.DateOfBirthField
        ]

        fresno_unexpected_fields = [
            F.SocialSecurityNumberField, F.CitizenshipStatus
        ]

        for field in fresno_expected_fields:
            with self.subTest(field=field):
                self.assertContains(response, field.context_key)

        for field in fresno_unexpected_fields:
            with self.subTest(field=field):
                self.assertNotContains(response, field.context_key)
        self.client.logout()

        santa_clara_profile = app_reviewer('santa_clara_pubdef')
        self.client.login(username=santa_clara_profile.user.username,
                          password=settings.TEST_USER_PASSWORD)
        response = self.client.get(self.edit_url)

        santa_clara_expected_fields = [
            F.ContactPreferences, F.FirstName, F.MiddleName, F.LastName,
            F.PhoneNumberField, F.AlternatePhoneNumberField, F.AddressField,
            F.EmailField, F.DateOfBirthField
        ]

        santa_clara_unexpected_fields = [
            F.SocialSecurityNumberField, F.Aliases, F.DriverLicenseOrIDNumber,
            F.MonthlyIncome
        ]

        for field in santa_clara_expected_fields:
            with self.subTest(field=field):
                self.assertContains(response, field.context_key)

        for field in santa_clara_unexpected_fields:
            with self.subTest(field=field):
                self.assertNotContains(response, field.context_key)
示例#3
0
 def test_matching_org_user_gets_200(self):
     matching_org_user_profile = app_reviewer('fresno_pubdef')
     self.client.login(
         username=matching_org_user_profile.user.username,
         password=settings.TEST_USER_PASSWORD)
     response = self.client.get(self.edit_url)
     self.assertEqual(200, response.status_code)
示例#4
0
 def test_org_user_is_redirected_to_profile(self):
     profile = app_reviewer()
     self.client.login(
         username=profile.user.username,
         password=settings.TEST_USER_PASSWORD)
     response = self.client.get(reverse('intake-app_cnl_index'))
     self.assertRedirects(response, reverse('user_accounts-profile'))
示例#5
0
 def test_edit_form_contains_existing_data_and_errors(self):
     fresno_profile = app_reviewer('fresno_pubdef')
     self.sub.answers['email'] = 'notgood@example'
     self.sub.answers['phone_number'] = '5555555555'
     self.sub.answers['alternate_phone_number'] = '5555555555'
     self.sub.answers['dob'] = {
         'month': 'February',
         'day': 3,
         'year': '19714'
     }
     self.sub.save()
     self.client.login(username=fresno_profile.user.username,
                       password=settings.TEST_USER_PASSWORD)
     response = self.client.get(self.edit_url)
     self.assertContains(response, self.sub.answers['first_name'])
     self.assertContains(response, self.sub.answers['last_name'])
     assertInputHasValue(response, 'phone_number', '')
     assertInputHasValue(response, 'existing_phone_number', '5555555555')
     assertInputHasValue(response, 'alternate_phone_number', '')
     assertInputHasValue(response, 'existing_alternate_phone_number',
                         '5555555555')
     assertInputHasValue(response, 'email', 'notgood@example')
     assertInputHasValue(response, 'existing_email', 'notgood@example')
     assertInputHasValue(response, 'dob.day', '3')
     assertInputHasValue(response, 'existing_dob.day', '3')
     assertInputHasValue(response, 'dob.month', '')
     assertInputHasValue(response, 'existing_dob.month', 'February')
     assertInputHasValue(response, 'dob.year', '19714')
     assertInputHasValue(response, 'existing_dob.year', '19714')
    def test_notifies_applicant_of_changed_data_with_correct_org_name_encoding(
            self, sms_notification_patch, email_notification_patch):
        alameda_profile = app_reviewer('a_pubdef')
        self.client.login(username=alameda_profile.user.username,
                          password=settings.TEST_USER_PASSWORD)
        response = self.client.get(self.edit_url)
        post_data = dict_to_post_data(
            response.context_data['form'].raw_input_data)
        post_data.update({
            'first_name': 'Foo',
            'last_name': 'Bar',
            'email': '*****@*****.**',
            'phone_number': '4153016005'
        })
        self.client.post(self.edit_url, post_data)
        organization = alameda_profile.organization
        expected_changed_fields = [
            'Email', 'First name', 'Last name', 'Phone number'
        ]
        email_notification_patch.send.assert_any_call(
            to=['*****@*****.**'],
            sender_profile=alameda_profile,
            org_contact_info=organization.get_contact_info_message(),
            org_name="the Alameda County Public Defender's Office",
            changed_fields=expected_changed_fields,
            is_old_contact_info=False)

        sms_notification_patch.send.assert_any_call(
            to=['4153016005'],
            org_contact_info=organization.get_contact_info_message(),
            org_name="the Alameda County Public Defender's Office",
            changed_fields=expected_changed_fields,
            is_old_contact_info=False)
 def test_org_user_from_correct_org_can_access(self):
     app_ids = intake_factories.make_app_ids_for('sf_pubdef')
     profile = user_accounts_factories.app_reviewer('sf_pubdef')
     login(self.client, profile)
     response = self.client.get(
         query_params.get_url_for_ids(self.view_name, app_ids))
     self.assertEqual(200, response.status_code)
示例#8
0
 def test_incorrect_org_user_gets_404(self):
     different_org_user_profile = app_reviewer('a_pubdef')
     self.client.login(
         username=different_org_user_profile.user.username,
         password=settings.TEST_USER_PASSWORD)
     response = self.client.get(self.edit_url)
     self.assertEqual(404, response.status_code)
示例#9
0
    def test_does_not_send_notifications_if_contact_info_does_not_exist(
            self, sms_notification_patch, email_notification_patch):
        self.sub.email = ''
        self.sub.phone_number = ''
        self.sub.answers['email'] = ''
        self.sub.answers['phone_number'] = ''
        self.sub.answers['contact_preferences'] = []
        self.sub.save()
        fresno_profile = app_reviewer('fresno_pubdef')
        self.client.login(username=fresno_profile.user.username,
                          password=settings.TEST_USER_PASSWORD)
        response = self.client.get(self.edit_url)
        post_data = dict_to_post_data(
            response.context_data['form'].raw_input_data)
        post_data.update({
            'first_name': 'Foo',
            'last_name': 'Bar',
            'phone_number': '4153016005'
        })

        self.client.post(self.edit_url, post_data)
        organization = fresno_profile.organization
        expected_changed_fields = ['First name', 'Last name', 'Phone number']
        email_notification_patch.send.assert_not_called()
        sms_notification_patch.send.assert_called_once_with(
            to=['4153016005'],
            org_contact_info=organization.get_contact_info_message(),
            org_name='the Fresno County Public Defender',
            changed_fields=expected_changed_fields,
            is_old_contact_info=False)
示例#10
0
 def test_does_not_show_csv_download_link(self):
     profile = app_reviewer('cc_pubdef')
     make_apps_for('cc_pubdef', count=1)
     self.client.login(username=profile.user.username,
                       password=settings.TEST_USER_PASSWORD)
     response = self.client.get(reverse(self.view_name))
     csv_download_link = reverse('intake-csv_download')
     self.assertNotContains(response, csv_download_link)
示例#11
0
 def test_if_invalid_ids(self, email_alert):
     app_ids = intake_factories.make_app_ids_for('cc_pubdef')
     profile = user_accounts_factories.app_reviewer('cc_pubdef')
     login(self.client, profile)
     response = self.client.get(
         query_params.get_url_for_ids(self.view_name, app_ids + [918274]))
     self.assertEqual(200, response.status_code)
     email_alert.assert_not_called()
示例#12
0
 def test_users_from_wrong_org_redirected_to_profile(self):
     profile = user_accounts_factories.app_reviewer('cc_pubdef')
     login(self.client, profile)
     sub = intake_factories.make_apps_for('a_pubdef',
                                          count=1)[0].form_submission
     response = self.client.get(
         reverse('intake-case_printout', kwargs=dict(submission_id=sub.id)))
     self.assertRedirects(response, reverse('user_accounts-profile'))
 def test_if_invalid_ids(self, email_alert):
     app_ids = intake_factories.make_app_ids_for('cc_pubdef')
     profile = user_accounts_factories.app_reviewer('cc_pubdef')
     login(self.client, profile)
     response = self.client.get(
         query_params.get_url_for_ids(self.view_name, app_ids + [918274]))
     self.assertEqual(200, response.status_code)
     email_alert.assert_not_called()
 def test_org_user_from_wrong_org_gets_not_allowed(self, email_alert):
     app_ids = intake_factories.make_app_ids_for('sf_pubdef')
     profile = user_accounts_factories.app_reviewer('a_pubdef')
     login(self.client, profile)
     response = self.client.get(
         query_params.get_url_for_ids(self.view_name, app_ids))
     self.assertRedirects(response, reverse('user_accounts-profile'))
     self.assertEqual(1, email_alert.call_count)
 def test_org_user_who_doesnt_need_prebuilt_gets_printout(self):
     app_ids = intake_factories.make_app_ids_for('a_pubdef')
     profile = user_accounts_factories.app_reviewer('a_pubdef')
     printout_url = query_params.get_url_for_ids(
         'intake-pdf_printout_for_apps', app_ids)
     login(self.client, profile)
     response = self.client.get(
         query_params.get_url_for_ids(self.view_name, app_ids))
     self.assertContains(response, printout_url)
示例#16
0
 def test_does_not_show_csv_download_link(self):
     profile = app_reviewer('cc_pubdef')
     make_apps_for('cc_pubdef', count=1)
     self.client.login(
         username=profile.user.username,
         password=settings.TEST_USER_PASSWORD)
     response = self.client.get(reverse(self.view_name))
     csv_download_link = reverse('intake-csv_download')
     self.assertNotContains(response, csv_download_link)
 def test_users_from_wrong_org_redirected_to_profile(self):
     profile = user_accounts_factories.app_reviewer('cc_pubdef')
     login(self.client, profile)
     sub = intake_factories.make_apps_for(
         'a_pubdef', count=1)[0].form_submission
     response = self.client.get(
         reverse(
             'intake-case_printout', kwargs=dict(submission_id=sub.id)))
     self.assertRedirects(response, reverse('user_accounts-profile'))
 def test_marks_apps_as_opened(self):
     app_ids = intake_factories.make_app_ids_for('sf_pubdef')
     profile = user_accounts_factories.app_reviewer('sf_pubdef')
     login(self.client, profile)
     self.client.get(
         query_params.get_url_for_ids(self.view_name, app_ids))
     all_apps_opened = all(models.Application.objects.filter(
         id__in=app_ids).values_list('has_been_opened', flat=True))
     self.assertTrue(all_apps_opened)
示例#19
0
 def test_only_gets_correct_emails(self):
     # users who shouldn't get notifications at an org that would
     fresno_user_w_notifications = app_reviewer('fresno_pubdef')
     fresno_user_without_notifications = app_reviewer(
         'fresno_pubdef', username='******')
     fresno_user_without_notifications.should_get_notifications = False
     fresno_user_without_notifications.save()
     santa_clara_user = app_reviewer('santa_clara_pubdef')
     app_reviewer('sf_pubdef')
     submission = FormSubmissionWithOrgsFactory(organizations=[
         santa_clara_user.organization,
         fresno_user_w_notifications.organization
     ])
     resulting_emails = set(get_emails_to_notify_of_edits(submission.id))
     expected_emails = {
         fresno_user_w_notifications.user.email, santa_clara_user.user.email
     }
     self.assertEqual(expected_emails, resulting_emails)
示例#20
0
 def test_org_user_w_no_apps_gets_empty_csv(self):
     user = accounts_factories.app_reviewer('ebclc').user
     cfa_apps = intake_factories.make_apps_for('cc_pubdef', count=1)
     self.client.login(username=user.username,
                       password=settings.TEST_USER_PASSWORD)
     response = self.client.get(reverse(self.view_name))
     self.assertEqual(200, response.status_code)
     df = pandas.read_csv(io.BytesIO(response.content))
     self.assertEqual(0, len(df))
示例#21
0
 def test_application_detail_doesnt_initiate_validation(self, validate):
     profile = app_reviewer('cc_pubdef')
     app = make_apps_for('cc_pubdef', count=1)[0]
     self.client.login(username=profile.user.username,
                       password=settings.TEST_USER_PASSWORD)
     self.client.get(
         reverse('intake-app_detail',
                 kwargs=dict(submission_id=app.form_submission_id)))
     validate.assert_not_called()
 def test_org_user_from_correct_org_can_access(self, get_bundle):
     get_bundle.return_value.pdf = b'bytez'
     app_ids = intake_factories.make_app_ids_for('sf_pubdef')
     prebuilt_pdf_for_ids(app_ids)
     profile = user_accounts_factories.app_reviewer('sf_pubdef')
     login(self.client, profile)
     response = self.client.get(
         query_params.get_url_for_ids(self.view_name, app_ids))
     self.assertEqual(200, response.status_code)
 def test_shows_flash_message(self):
     app_ids = intake_factories.make_app_ids_for('sf_pubdef', count=3)
     profile = user_accounts_factories.app_reviewer('sf_pubdef')
     login(self.client, profile)
     response = self.client.get(
         query_params.get_url_for_ids(self.view_name, app_ids))
     self.assertContains(response, str(
         '3 applications have been marked as “Read” and moved to the '
         '“Needs Status Update” folder'))
 def test_ignores_invalid_ids(self, email_alert, get_bundle):
     app_ids = intake_factories.make_app_ids_for('sf_pubdef')
     prebuilt_pdf_for_ids(app_ids)
     get_bundle.return_value.pdf = b'bytez'
     profile = user_accounts_factories.app_reviewer('sf_pubdef')
     login(self.client, profile)
     response = self.client.get(
         query_params.get_url_for_ids(self.view_name, app_ids + [918274]))
     self.assertEqual(200, response.status_code)
     email_alert.assert_not_called()
 def test_fires_expected_mixpanel_events(self):
     app_ids = intake_factories.make_app_ids_for('sf_pubdef')
     profile = user_accounts_factories.app_reviewer('sf_pubdef')
     login(self.client, profile)
     with self.assertLogs(
             'project.services.logging_service', logging.INFO) as logs:
         response = self.client.get(
             query_params.get_url_for_ids(self.view_name, app_ids))
     assertInLogsCount(logs, {'event_name=app_opened': len(app_ids)})
     assertInLogsCount(logs, {'event_name=user_app_opened': len(app_ids)})
 def test_invalid_query_params_returns_not_allowed(self, email_alert):
     prebuilt = intake_factories.PrebuiltPDFBundleFactory()
     app_ids = intake_factories.make_app_ids_for('sf_pubdef')
     prebuilt.applications.add(*app_ids)
     profile = user_accounts_factories.app_reviewer('sf_pubdef')
     login(self.client, profile)
     response = self.client.get(
         query_params.get_url_for_ids(self.view_name, app_ids + ['omg']))
     self.assertRedirects(response, reverse('user_accounts-profile'))
     self.assertEqual(1, email_alert.call_count)
 def test_org_user_who_needs_prebuilt_sees_prebuilt_link(self):
     intake_factories.FillablePDFFactory()
     prebuilt = intake_factories.PrebuiltPDFBundleFactory()
     app_ids = intake_factories.make_app_ids_for('sf_pubdef')
     prebuilt.applications.add(*app_ids)
     profile = user_accounts_factories.app_reviewer('sf_pubdef')
     login(self.client, profile)
     response = self.client.get(
         query_params.get_url_for_ids(self.view_name, app_ids))
     self.assertContains(response, prebuilt.get_absolute_url())
 def test_application_detail_doesnt_initiate_validation(self, validate):
     profile = app_reviewer('cc_pubdef')
     app = make_apps_for('cc_pubdef', count=1)[0]
     self.client.login(
         username=profile.user.username,
         password=settings.TEST_USER_PASSWORD)
     self.client.get(reverse(
         'intake-app_detail', kwargs=dict(
             submission_id=app.form_submission_id)))
     validate.assert_not_called()
示例#29
0
 def test_user_sees_correct_columns_and_data_in_csv(self):
     user = accounts_factories.app_reviewer('ebclc').user
     ebclc = Organization.objects.get(slug='ebclc')
     sub = intake_factories.FormSubmissionWithOrgsFactory(
         organizations=[ebclc], answers=ebclc_answers)
     app = sub.applications.first()
     update_1 = intake_factories.StatusUpdateFactory(
         application=app,
         status_type=StatusType.objects.get(slug='eligible'),
         author=user
     )
     update_1.created = PACIFIC_TIME.localize(datetime(2017, 1, 1))
     update_1.save()
     update_2 = intake_factories.StatusUpdateFactory(
         application=app,
         status_type=StatusType.objects.get(slug='granted'),
         author=user
     )
     update_2.created = PACIFIC_TIME.localize(datetime(2017, 1, 2))
     update_2.save()
     self.client.login(
         username=user.username, password=settings.TEST_USER_PASSWORD)
     response = self.client.get(reverse(self.view_name))
     self.assertEqual(200, response.status_code)
     result = response.content.decode('utf-8')
     expected_result_line_1 = str(
         'id,Link,Application Date,Applied on,Wants help with record in,'
         'Preferred contact methods,First name,Middle name,'
         'Last name,Preferred pronouns,Phone number,Alternate phone number,'
         'Email,Address,Date of birth,Citizenship status,'
         'Is currently being charged,Is serving a sentence,'
         'Is on probation or parole,Finished half probation,'
         'Reduced probation,RAP in other counties,Where/when,'
         'Has suspended license,Owes court fines/fees,'
         'Has been denied housing or employment,'
         'Denied housing/employment by,Seeking job that requires LiveScan,'
         'Registered under PC 290,'
         'Monthly income,On public benefits,Owns home,Household size,'
         'Reasons for applying,How they found out about this,'
         'Additional information,'
         'Understands might not qualify and could take a few months,'
         '"Consents to record access, filing, and court representation",'
         'Was transferred out,Has been opened,Latest status,'
         'Latest status date,Latest status author,Status history link')
     expected_result_line_2 = str(
         'Alameda,Text Message,Gabriel,Tiffany,Jenkins,She/Her/Hers,'
         '(415) 212-4848,(415) 212-4848,[email protected],'
         '"6230 Shawn View\nNorth John, VA\n80973",4/19/1983,'
         'Other/I don\'t know,No,No,Yes,Not on probation,Not on probation,'
         'No,,No,No,,,,,"$3,001.00",No,Yes,3,,from work,I want help,'
         '"Yes, I understand","Yes, I give them permission to do that",'
         'False,False,Granted,01/02/2017,[email protected],')
     self.assertIn(expected_result_line_1, result)
     self.assertTrue(result.startswith(expected_result_line_1))
     self.assertIn(expected_result_line_2, result)
示例#30
0
 def test_does_not_notify_if_unchanged(self, applicant_notification_patch,
                                       org_notification_patch):
     fresno_profile = app_reviewer('fresno_pubdef')
     self.client.login(username=fresno_profile.user.username,
                       password=settings.TEST_USER_PASSWORD)
     response = self.client.get(self.edit_url)
     post_data = dict_to_post_data(
         response.context_data['form'].raw_input_data)
     self.client.post(self.edit_url, post_data)
     org_notification_patch.assert_not_called()
     applicant_notification_patch.assert_not_called()
示例#31
0
 def test_marks_apps_as_opened(self, slack):
     profile = user_accounts_factories.app_reviewer('a_pubdef')
     login(self.client, profile)
     submission = intake_factories.make_apps_for('a_pubdef',
                                                 count=1)[0].form_submission
     response = self.client.get(
         reverse('intake-case_printout',
                 kwargs=dict(submission_id=submission.id)))
     application = submission.applications.filter(
         organization=profile.organization).first()
     self.assertTrue(application.has_been_opened)
 def test_fires_expected_mixpanel_events(self):
     profile = user_accounts_factories.app_reviewer('a_pubdef')
     login(self.client, profile)
     submission = intake_factories.make_apps_for(
                 'a_pubdef', count=1)[0].form_submission
     with self.assertLogs(
             'project.services.logging_service', logging.INFO) as logs:
         self.client.get(
             reverse('intake-case_printout', kwargs=dict(
                     submission_id=submission.id)))
     assertInLogsCount(logs, {'event_name=app_opened': 1})
     assertInLogsCount(logs, {'event_name=user_app_opened': 1})
 def test_marks_apps_as_opened(self):
     profile = user_accounts_factories.app_reviewer('a_pubdef')
     login(self.client, profile)
     submission = intake_factories.make_apps_for(
                 'a_pubdef', count=1)[0].form_submission
     self.client.get(
         reverse(
             'intake-case_printout', kwargs=dict(
                 submission_id=submission.id)))
     application = submission.applications.filter(
         organization=profile.organization).first()
     self.assertTrue(application.has_been_opened)
示例#34
0
 def test_org_user_w_no_apps_gets_empty_csv(self):
     user = accounts_factories.app_reviewer('ebclc').user
     cfa_apps = intake_factories.make_apps_for('cc_pubdef', count=1)
     self.client.login(
         username=user.username, password=settings.TEST_USER_PASSWORD)
     response = self.client.get(reverse(self.view_name))
     self.assertEqual(200, response.status_code)
     reader = csv.DictReader(io.StringIO(response.content.decode('utf-8')))
     rows = []
     for row in reader:
         rows.append(row)
     self.assertEqual(len(rows), 0)
示例#35
0
 def test_fires_expected_mixpanel_events(self, slack):
     profile = user_accounts_factories.app_reviewer('a_pubdef')
     login(self.client, profile)
     submission = intake_factories.make_apps_for('a_pubdef',
                                                 count=1)[0].form_submission
     with self.assertLogs('project.services.logging_service',
                          logging.INFO) as logs:
         self.client.get(
             reverse('intake-case_printout',
                     kwargs=dict(submission_id=submission.id)))
     assertInLogsCount(logs, {'event_name=app_opened': 1})
     assertInLogsCount(logs, {'event_name=user_app_opened': 1})
示例#36
0
    def test_notifies_applicant_of_changed_data_at_old_and_new_contact_info(
            self, sms_notification_patch, email_notification_patch):
        fresno_profile = app_reviewer('fresno_pubdef')
        self.client.login(username=fresno_profile.user.username,
                          password=settings.TEST_USER_PASSWORD)
        response = self.client.get(self.edit_url)
        post_data = dict_to_post_data(
            response.context_data['form'].raw_input_data)
        post_data.update({
            'first_name': 'Foo',
            'last_name': 'Bar',
            'driver_license_or_id': '9123462907890387',
            'email': '*****@*****.**',
            'phone_number': '4153016005'
        })
        self.client.post(self.edit_url, post_data)
        organization = fresno_profile.organization
        expected_changed_fields = [
            'Driver License/ID', 'Email', 'First name', 'Last name',
            'Phone number'
        ]
        email_notification_patch.send.assert_any_call(
            to=['*****@*****.**'],
            sender_profile=fresno_profile,
            org_contact_info=organization.get_contact_info_message(),
            org_name='the Fresno County Public Defender',
            changed_fields=expected_changed_fields,
            is_old_contact_info=False)

        email_notification_patch.send.assert_any_call(
            to=[self.sub.email],
            sender_profile=fresno_profile,
            org_contact_info=organization.get_contact_info_message(),
            org_name='the Fresno County Public Defender',
            changed_fields=expected_changed_fields,
            is_old_contact_info=True)
        self.assertEqual(2, len(email_notification_patch.send.mock_calls))

        sms_notification_patch.send.assert_any_call(
            to=['(415) 212-4848'],
            org_contact_info=organization.get_contact_info_message(),
            org_name='the Fresno County Public Defender',
            changed_fields=expected_changed_fields,
            is_old_contact_info=True)

        sms_notification_patch.send.assert_any_call(
            to=['4153016005'],
            org_contact_info=organization.get_contact_info_message(),
            org_name='the Fresno County Public Defender',
            changed_fields=expected_changed_fields,
            is_old_contact_info=False)
        self.assertEqual(2, len(sms_notification_patch.send.mock_calls))
示例#37
0
 def test_submitting_unchanged_existing_bad_data_is_not_allowed(self):
     # add existing bad data
     self.sub.answers['email'] = 'notgood@example'
     self.sub.save()
     fresno_profile = app_reviewer('fresno_pubdef')
     self.client.login(username=fresno_profile.user.username,
                       password=settings.TEST_USER_PASSWORD)
     response = self.client.get(self.edit_url)
     post_data = dict_to_post_data(
         response.context_data['form'].raw_input_data)
     post_data.update({'first_name': 'Foo', 'last_name': 'Bar'})
     response = self.client.post(self.edit_url, post_data)
     self.assertEqual(200, response.status_code)