コード例 #1
0
 def test_org_user_from_correct_org_can_access(self):
     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))
     self.assertEqual(200, response.status_code)
コード例 #2
0
 def test_followup_user_can_access(self):
     app_ids = intake_factories.make_app_ids_for('sf_pubdef')
     profile = user_accounts_factories.followup_user()
     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)
コード例 #3
0
 def test_org_user_from_correct_org_can_access(self):
     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))
     self.assertEqual(200, response.status_code)
コード例 #4
0
 def test_monitor_user_gets_not_allowed(self, email_alert):
     app_ids = intake_factories.make_app_ids_for('sf_pubdef')
     profile = user_accounts_factories.monitor_user()
     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)
コード例 #5
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()
コード例 #6
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()
コード例 #7
0
 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)
コード例 #8
0
 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)
コード例 #9
0
 def test_followup_user_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.followup_user()
     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)
コード例 #10
0
 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'))
コード例 #11
0
 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)
コード例 #12
0
 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())
コード例 #13
0
 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()
コード例 #14
0
 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)})