Esempio n. 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)
 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)
 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)
Esempio n. 4
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()
 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_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)
Esempio n. 7
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_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)
Esempio n. 9
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)
 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)
 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)
 def test_delete_device_form_is_csrf_protected(self, prodapp, db, user,
                                               sample_device):
     login(prodapp, user.email, "admin")
     assert Device.query.count() == 1
     response = prodapp.post("/admin/device/delete/",
                             params=dict(id=sample_device.id,
                                         url="/admin/device/")).follow()
     assert b"Failed to delete record. CSRF Token: CSRF token missing" in response
     assert Device.query.count() == 1
 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)
 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'))
Esempio n. 15
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_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_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)})
Esempio n. 20
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)
Esempio n. 21
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)
Esempio n. 22
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})
Esempio n. 23
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})
Esempio n. 24
0
    def test_export(self, user, sample_repair, another_repair, db, testapp):
        login(testapp, user.email, "admin")
        response = testapp.get("http://localhost:5000/admin/repair/export/csv/")
        cr = csv.reader(response.text.splitlines(), delimiter=',')

        result = list(cr)

        assert len(result) == Repair.query.count() + 1

        for repair in Repair.query.all():
            entry = [
                repair.device.manufacturer.name,
                repair.device.series.name,
                repair.device.name,
                repair.name,
                "".join(color.name for color in repair.device.colors),
                str(repair.price)
            ]
            assert entry in result
Esempio n. 25
0
 def test_admin_login_shortcut(self, user, testapp):
     response = login(testapp, user.email, "admin")
     assert "Hier kannst du alle nötigen Einstellungen vornehmen und Geräte, sowie Reparaturen anlegen.".encode(
         'utf-8') in response