예제 #1
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)
예제 #2
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)
예제 #3
0
 def test_queries_and_notifications_for_each_org(self, get_orgs):
     a_pubdef = auth_models.Organization.objects.get(slug='a_pubdef')
     make_apps_for(a_pubdef.slug, count=3)
     # assume we only receive one org back
     get_orgs.return_value = [a_pubdef]
     with self.assertNumQueries(4):
         BundlesService.count_unreads_and_send_notifications_to_orgs()
     self.assertEqual(
         self.notifications.front_email_daily_app_bundle.send.call_count, 1)
예제 #4
0
 def test_get_all_unhandled_cnl_apps(self):
     apps = factories.make_apps_for('cfa', count=3)
     unexpected_apps = factories.make_apps_for('cc_pubdef', count=2)
     results = list(AppsService.get_all_unhandled_cnl_apps())
     for app in apps:
         with self.subTest(app=app):
             self.assertIn(app, results)
     for app in unexpected_apps:
         with self.subTest(app=app):
             self.assertNotIn(app, results)
 def test_get_all_unhandled_cnl_apps(self):
     apps = factories.make_apps_for('cfa', count=3)
     unexpected_apps = factories.make_apps_for('cc_pubdef', count=2)
     results = list(AppsService.get_all_unhandled_cnl_apps())
     for app in apps:
         with self.subTest(app=app):
             self.assertIn(app, results)
     for app in unexpected_apps:
         with self.subTest(app=app):
             self.assertNotIn(app, results)
예제 #6
0
 def test_queries_and_notifications_for_each_org(self, get_orgs):
     a_pubdef = auth_models.Organization.objects.get(
         slug='a_pubdef')
     make_apps_for(a_pubdef.slug, count=3)
     # assume we only receive one org back
     get_orgs.return_value = [a_pubdef]
     with self.assertNumQueries(4):
         BundlesService.count_unreads_and_send_notifications_to_orgs()
     self.assertEqual(
         self.notifications.front_email_daily_app_bundle.send.call_count, 1)
예제 #7
0
 def test_counts_and_notification_args_for_unreads(self, send_email):
     email, org = self.email_and_org()
     make_apps_for(org.slug, count=3, answers={})
     BundlesService.count_unreads_and_send_notifications_to_orgs()
     send_email.assert_called_once_with(
         to=[email],
         org_name=org.name,
         unread_count=3,
         update_count=3,
         all_count=3,
         unread_redirect_link=external_reverse(
             'intake-unread_email_redirect'),
         needs_update_redirect_link=external_reverse(
             'intake-needs_update_email_redirect'),
         all_redirect_link=external_reverse('intake-all_email_redirect'))
예제 #8
0
 def test_followup_staff_gets_not_listed_apps(self):
     user = accounts_factories.followup_user().user
     cfa_apps = intake_factories.make_apps_for('cfa', count=1)
     ebclc_apps = intake_factories.make_apps_for('ebclc', 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))
     for app in cfa_apps:
         with self.subTest(app=app):
             self.assertTrue(any(df.id == app.form_submission_id))
     for app in ebclc_apps:
         with self.subTest(app=app):
             self.assertFalse(any(df.id == app.form_submission_id))
예제 #9
0
 def test_org_user_gets_apps_from_own_org_only(self):
     user = accounts_factories.app_reviewer('ebclc').user
     cc_apps = intake_factories.make_apps_for('cc_pubdef', count=1)
     ebclc_apps = intake_factories.make_apps_for('ebclc', 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))
     for app in cc_apps:
         with self.subTest(app=app):
             self.assertFalse(any(df.id == app.form_submission_id))
     for app in ebclc_apps:
         with self.subTest(app=app):
             self.assertTrue(any(df.id == app.form_submission_id))
예제 #10
0
 def test_anonymous_users_redirected_to_login(self):
     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.assertIn(reverse('user_accounts-login'), response.url)
     self.assertEqual(response.status_code, 302)
예제 #11
0
 def test_counts_and_notification_args_for_unreads(self, send_email):
     email, org = self.email_and_org()
     make_apps_for(org.slug, count=3, answers={})
     BundlesService.count_unreads_and_send_notifications_to_orgs()
     send_email.assert_called_once_with(
             to=[email],
             org_name=org.name,
             unread_count=3,
             update_count=3,
             all_count=3,
             unread_redirect_link=external_reverse(
                 'intake-unread_email_redirect'),
             needs_update_redirect_link=external_reverse(
                 'intake-needs_update_email_redirect'),
             all_redirect_link=external_reverse(
                 'intake-all_email_redirect'))
예제 #12
0
 def test_counts_and_notification_args_for_no_unreads(self, send_email):
     email, org = self.email_and_org()
     apps = make_apps_for(org.slug, count=3, answers={})
     for app in apps:
         app.has_been_opened = True
         app.save()
     BundlesService.count_unreads_and_send_notifications_to_orgs()
     send_email.assert_not_called()
예제 #13
0
 def test_anonymous_users_redirected_to_login(self):
     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.assertIn(reverse('user_accounts-login'), response.url)
     self.assertEqual(response.status_code, 302)
예제 #14
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'))
예제 #15
0
 def test_counts_and_notification_args_for_no_unreads(self, send_email):
     email, org = self.email_and_org()
     apps = make_apps_for(org.slug, count=3, answers={})
     for app in apps:
         app.has_been_opened = True
         app.save()
     BundlesService.count_unreads_and_send_notifications_to_orgs()
     send_email.assert_not_called()
예제 #16
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'))
예제 #17
0
 def test_org_user_gets_apps_from_own_org_only(self):
     user = accounts_factories.app_reviewer('ebclc').user
     cc_apps = intake_factories.make_apps_for('cc_pubdef', count=1)
     ebclc_apps = intake_factories.make_apps_for('ebclc', 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')))
     ids = []
     for row in reader:
         ids.append(int(row['id']))
     for app in cc_apps:
         with self.subTest(app=app):
             self.assertNotIn(app.form_submission_id, ids)
     for app in ebclc_apps:
         with self.subTest(app=app):
             self.assertIn(app.form_submission_id, ids)
예제 #18
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()
예제 #19
0
 def test_cfa_staff_can_view(self):
     profile = user_accounts_factories.followup_user()
     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)))
     self.assertEqual(response.status_code, 200)
예제 #20
0
 def test_cfa_staff_can_view(self):
     profile = user_accounts_factories.followup_user()
     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)))
     self.assertEqual(response.status_code, 200)
예제 #21
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))
 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()
예제 #23
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)
예제 #24
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})
예제 #25
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)
예제 #26
0
 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)
예제 #27
0
 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})
예제 #28
0
 def test_counts_and_notification_args_for_no_unreads(
         self, slack, send_email):
     email, org = self.email_and_org()
     apps = make_apps_for(org.slug, count=3, answers={})
     for app in apps:
         app.has_been_opened = True
         app.save()
     BundlesService.count_unreads_and_send_notifications_to_orgs()
     send_email.assert_not_called()
     slack.assert_called_once_with(org_name=org.name,
                                   emails=[email],
                                   unread_count=0,
                                   update_count=3,
                                   all_count=3)