Exemplo n.º 1
0
    def test_review_post_audit_exists(self):
        self._create_and_login_user(username='******')
        tally = create_tally()
        tally.users.add(self.user)
        result_form = create_result_form(form_state=FormState.AUDIT,
                                         tally=tally)
        create_audit(result_form, self.user)
        self._create_and_login_user()
        self._add_user_to_group(self.user, groups.AUDIT_CLERK)
        tally.users.add(self.user)

        view = views.ReviewView.as_view()
        data = {
            'result_form': result_form.pk,
            'action_prior_to_recommendation': 1,
            'resolution_recommendation': 0,
            'tally_id': tally.pk,
        }
        request = self.factory.post('/', data=data)
        request.user = self.user
        request.session = data
        response = view(request, tally_id=tally.pk)

        self.assertEqual(response.status_code, 302)

        audit = result_form.audit
        self.assertEqual(audit.user, self.user)
        self.assertEqual(audit.reviewed_team, False)
        self.assertEqual(audit.action_prior_to_recommendation,
                         ActionsPrior.REQUEST_AUDIT_ACTION_FROM_FIELD)
Exemplo n.º 2
0
    def test_print_quarantine_get(self):
        self._create_and_login_user()
        tally = create_tally()
        tally.users.add(self.user)
        code = '12345'
        station_number = 1
        center = create_center(code, tally=tally)
        create_station(center)
        result_form = create_result_form(form_state=FormState.QUALITY_CONTROL,
                                         center=center,
                                         tally=tally,
                                         station_number=station_number)
        quarantine_check = QuarantineCheck.objects.create(user=self.user,
                                                          name='1',
                                                          method='1',
                                                          value=1)
        audit = create_audit(result_form, self.user)
        audit.quarantine_checks.add(quarantine_check)

        self._add_user_to_group(self.user, groups.QUALITY_CONTROL_CLERK)
        view = views.PrintView.as_view()
        request = self.factory.get('/')
        request.session = {'result_form': result_form.pk}
        request.user = self.user
        response = view(request, tally_id=tally.pk)

        self.assertEqual(response.status_code, 200)
        self.assertContains(response, 'Quarantined')
Exemplo n.º 3
0
    def test_form_action_view_post_confirm_audit(self):
        result_form = create_result_form(form_state=FormState.AUDIT)
        create_reconciliation_form(result_form, self.user)
        create_reconciliation_form(result_form, self.user)
        create_candidates(result_form, self.user)
        audit = create_audit(result_form, self.user)

        request = self._get_request()
        view = views.FormActionView.as_view()
        data = {'result_form': result_form.pk, 'confirm': 1}
        request = self.factory.post('/', data=data)
        request.user = self.user
        request.session = {'result_form': result_form.pk}
        response = view(request)

        audit.reload()
        result_form.reload()
        self.assertFalse(audit.active)
        self.assertEqual(result_form.form_state, FormState.DATA_ENTRY_1)
        self.assertTrue(result_form.skip_quarantine_checks)

        self.assertEqual(len(result_form.results.all()), 20)
        self.assertEqual(len(result_form.reconciliationform_set.all()), 2)

        for result in result_form.results.all():
            self.assertFalse(result.active)

        for result in result_form.reconciliationform_set.all():
            self.assertFalse(result.active)

        self.assertEqual(response.status_code, 302)
        self.assertIn('/super-administrator/form-action-list',
                      response['Location'])
Exemplo n.º 4
0
    def test_dashboard_get_supervisor(self):
        username = '******'
        self._create_and_login_user(username=username)
        result_form = create_result_form(form_state=FormState.AUDIT,
                                         station_number=42)
        create_audit(result_form, self.user, reviewed_team=True)
        self._create_and_login_user()
        self._add_user_to_group(self.user, groups.AUDIT_SUPERVISOR)
        request = self.factory.get('/')
        request.user = self.user
        view = views.DashboardView.as_view()
        response = view(request)

        self.assertContains(response, 'Audit')
        self.assertContains(response, username)
        self.assertContains(response, '42')
Exemplo n.º 5
0
    def test_dashboard_get_supervisor(self):
        username = '******'
        self._create_and_login_user(username=username)
        result_form = create_result_form(form_state=FormState.AUDIT,
                                         station_number=42)
        create_audit(result_form, self.user, reviewed_team=True)
        self._create_and_login_user()
        self._add_user_to_group(self.user, groups.AUDIT_SUPERVISOR)
        request = self.factory.get('/')
        request.user = self.user
        view = views.DashboardView.as_view()
        response = view(request)

        self.assertContains(response, 'Audit')
        self.assertContains(response, username)
        self.assertContains(response, '42')
Exemplo n.º 6
0
    def test_print_quarantine_get(self):
        self._create_and_login_user()
        code = '12345'
        station_number = 1
        center = create_center(code)
        create_station(center)
        result_form = create_result_form(form_state=FormState.ARCHIVING,
                                         center=center,
                                         station_number=station_number)
        quarantine_check = QuarantineCheck.objects.create(
            user=self.user,
            name='1',
            method='1',
            value=1)
        audit = create_audit(result_form, self.user)
        audit.quarantine_checks.add(quarantine_check)

        self._add_user_to_group(self.user, groups.ARCHIVE_CLERK)
        view = views.ArchivePrintView.as_view()
        request = self.factory.get('/')
        request.session = {'result_form': result_form.pk}
        request.user = self.user
        response = view(request)

        self.assertEqual(response.status_code, 200)
        self.assertContains(response, 'Quarantined')
Exemplo n.º 7
0
    def test_form_action_view_post_confirm_audit(self):
        result_form = create_result_form(form_state=FormState.AUDIT)
        create_reconciliation_form(result_form, self.user)
        create_reconciliation_form(result_form, self.user)
        create_candidates(result_form, self.user)
        audit = create_audit(result_form, self.user)

        request = self._get_request()
        view = views.FormActionView.as_view()
        data = {'result_form': result_form.pk,
                'confirm': 1}
        request = self.factory.post('/', data=data)
        request.user = self.user
        request.session = {'result_form': result_form.pk}
        response = view(request)

        audit.reload()
        result_form.reload()
        self.assertFalse(audit.active)
        self.assertEqual(result_form.form_state, FormState.DATA_ENTRY_1)
        self.assertTrue(result_form.skip_quarantine_checks)

        self.assertEqual(len(result_form.results.all()), 20)
        self.assertEqual(len(result_form.reconciliationform_set.all()),
                         2)

        for result in result_form.results.all():
            self.assertFalse(result.active)

        for result in result_form.reconciliationform_set.all():
            self.assertFalse(result.active)

        self.assertEqual(response.status_code, 302)
        self.assertIn('/super-administrator/form-action-list',
                      response['Location'])
Exemplo n.º 8
0
    def test_review_post_audit_exists(self):
        self._create_and_login_user(username='******')
        result_form = create_result_form(form_state=FormState.AUDIT)
        create_audit(result_form, self.user)
        self._create_and_login_user()
        self._add_user_to_group(self.user, groups.AUDIT_CLERK)

        view = views.ReviewView.as_view()
        data = {'result_form': result_form.pk,
                'action_prior_to_recommendation': 1,
                'resolution_recommendation': 0}
        request = self.factory.post('/', data=data)
        request.user = self.user
        request.session = data
        response = view(request)

        audit = result_form.audit
        self.assertEqual(audit.user, self.user)
        self.assertEqual(audit.reviewed_team, False)
        self.assertEqual(audit.action_prior_to_recommendation, 1)
        self.assertEqual(response.status_code, 302)
Exemplo n.º 9
0
 def test_audit_quarantine_check_name_property_method(self):
     """Test audit quarantine check name property method"""
     result_form = create_result_form()
     quarantine_check = QuarantineCheck.objects.create(user=self.user,
                                                       name='1',
                                                       method='1',
                                                       value=1)
     audit = create_audit(result_form, self.user)
     audit.quarantine_checks.add(quarantine_check)
     self.assertQuerysetEqual(
         result_form.audit_quaritine_checks,
         map(repr,
             audit.quarantine_checks.all().values('name')))
Exemplo n.º 10
0
    def test_review_post_audit_exists(self):
        self._create_and_login_user(username='******')
        result_form = create_result_form(form_state=FormState.AUDIT)
        create_audit(result_form, self.user)
        self._create_and_login_user()
        self._add_user_to_group(self.user, groups.AUDIT_CLERK)

        view = views.ReviewView.as_view()
        data = {
            'result_form': result_form.pk,
            'action_prior_to_recommendation': 1,
            'resolution_recommendation': 0
        }
        request = self.factory.post('/', data=data)
        request.user = self.user
        request.session = data
        response = view(request)

        audit = result_form.audit
        self.assertEqual(audit.user, self.user)
        self.assertEqual(audit.reviewed_team, False)
        self.assertEqual(audit.action_prior_to_recommendation, 1)
        self.assertEqual(response.status_code, 302)
Exemplo n.º 11
0
    def test_dashboard_get_supervisor(self):
        username = '******'
        self._create_and_login_user(username=username)
        tally = create_tally()
        tally.users.add(self.user)
        result_form = create_result_form(form_state=FormState.AUDIT,
                                         tally=tally,
                                         station_number=42)
        quarantine_check = QuarantineCheck.objects.create(
            user=self.user,
            name='Guard against overvoting',
            method='1',
            value=1)
        audit = create_audit(result_form, self.user, reviewed_team=True)
        audit.quarantine_checks.add(quarantine_check)
        self._create_and_login_user()
        self._add_user_to_group(self.user, groups.AUDIT_SUPERVISOR)
        tally.users.add(self.user)
        request = self.factory.get('/')
        request.user = self.user
        view = views.DashboardView.as_view()
        response = view(request, tally_id=tally.pk)

        self.assertContains(response, '<h1>Audit List</h1>')
        self.assertContains(response, '<th>Barcode</th>')
        self.assertContains(response, '<th>Center Name</th>')
        self.assertContains(response, '<th>Center ID</th>')
        self.assertContains(response, '<th>Station</th>')
        self.assertContains(response, '<th>Reviewed?</th>')
        self.assertContains(response, '<th>Supervisor Reviewed?</th>')
        self.assertContains(response, '<th>Modified Date</th>')
        self.assertContains(response, '<th>Quaritine Check</th>')
        self.assertContains(response, '<th>Review</th>')
        self.assertContains(response, username)
        self.assertContains(response, '42')
        self.assertContains(response, 'Guard against overvoting')