コード例 #1
0
ファイル: test_archive.py プロジェクト: ben12345/tally-ho
    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')
コード例 #2
0
ファイル: test_data_entry.py プロジェクト: ben12345/tally-ho
    def test_enter_results_success_data_entry_one(self):
        code = '12345'
        center = create_center(code)
        create_station(center)
        result_form = create_result_form(form_state=FormState.DATA_ENTRY_1,
                                         center=center)
        ballot = result_form.ballot
        candidate_name = 'candidate name'
        create_candidate(ballot, candidate_name)

        self._create_and_login_user()
        self._add_user_to_group(self.user, groups.DATA_ENTRY_1_CLERK)

        response = self._post_enter_results(result_form)

        self.assertEqual(response.status_code, 302)
        self.assertIn('data-entry',
                      response['location'])
        result_form.reload()
        self.assertEqual(result_form.form_state,
                         FormState.DATA_ENTRY_2)

        reconciliation_forms = result_form.reconciliationform_set.all()
        self.assertEqual(len(reconciliation_forms), 1)
        self.assertEqual(reconciliation_forms[0].entry_version,
                         EntryVersion.DATA_ENTRY_1)

        results = result_form.results.all()
        self.assertEqual(len(results), 1)
        self.assertEqual(results[0].entry_version, EntryVersion.DATA_ENTRY_1)

        for result in results:
            self.assertEqual(result.user, self.user)
コード例 #3
0
ファイル: test_archive.py プロジェクト: ben12345/tally-ho
    def test_archive_post_quarantine_pass_with_zero_diff(self):
        center = create_center()
        create_station(center)
        create_quarantine_checks()
        self._create_and_login_user()
        barcode = '123456789'
        result_form = create_result_form(
            form_state=FormState.ARCHIVING,
            center=center, station_number=1)
        recon_form = create_reconciliation_form(
            result_form, self.user, number_unstamped_ballots=0)
        self._add_user_to_group(self.user, groups.ARCHIVE_CLERK)
        view = views.ArchiveView.as_view()
        data = {'barcode': barcode, 'barcode_copy': barcode}
        request = self.factory.post('/', data=data)
        request.session = {}
        request.user = self.user
        response = view(request)
        result_form.reload()

        self.assertEqual(result_form.num_votes,
                         recon_form.number_ballots_expected)

        self.assertEqual(response.status_code, 302)
        self.assertTrue(result_form.form_state, FormState.AUDIT)
        self.assertIsNone(result_form.audit)
        self.assertEqual(result_form.audited_count, 0)
        self.assertIn('archive/print', response['location'])
コード例 #4
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')
コード例 #5
0
 def test_center_detail_redirects_to_enter_results(self):
     self._create_and_login_user()
     self._add_user_to_group(self.user, groups.DATA_ENTRY_1_CLERK)
     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.DATA_ENTRY_1,
                                      center=center,
                                      tally=tally,
                                      station_number=station_number)
     view = views.CenterDetailsView.as_view()
     result_form_data = {'result_form': result_form.pk}
     data = center_data(code,
                        station_number=station_number,
                        tally_id=tally.pk)
     data.update(result_form_data)
     request = self.factory.post('/', data=data)
     request.user = self.user
     request.session = result_form_data
     response = view(request, tally_id=tally.pk)
     self.assertEqual(response.status_code, 302)
     self.assertIn('data-entry/enter-results',
                   response['location'])
コード例 #6
0
ファイル: test_data_entry.py プロジェクト: onaio/tally-ho
 def test_center_detail_center_alpha_numeric(self):
     self._create_and_login_user()
     self._add_user_to_group(self.user, groups.DATA_ENTRY_1_CLERK)
     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.DATA_ENTRY_1,
                                      center=center,
                                      tally=tally,
                                      station_number=station_number)
     view = views.CenterDetailsView.as_view()
     data = center_data('12345', '12346')
     data['center_number'] = 'abcde'
     data['center_number_copy'] = 'abcde'
     session = {'result_form': result_form.pk}
     data.update(session)
     request = self.factory.post('/', data=data)
     request.user = self.user
     request.session = session
     response = view(request, tally_id=tally.pk)
     self.assertContains(response,
                         u'Expecting only numbers for center number')
コード例 #7
0
    def test_archive_post_quarantine_pass_with_zero_diff(self):
        center = create_center()
        create_station(center)
        create_quarantine_checks()
        self._create_and_login_user()
        barcode = '123456789'
        result_form = create_result_form(form_state=FormState.ARCHIVING,
                                         center=center,
                                         station_number=1)
        recon_form = create_reconciliation_form(result_form,
                                                self.user,
                                                number_unstamped_ballots=0)
        self._add_user_to_group(self.user,
                                groups.QUALITY_CONTROL_ARCHIVE_CLERK)
        view = views.ArchiveView.as_view()
        data = {'barcode': barcode, 'barcode_copy': barcode}
        request = self.factory.post('/', data=data)
        request.session = {}
        request.user = self.user
        response = view(request)
        result_form.reload()

        self.assertEqual(result_form.num_votes,
                         recon_form.number_ballots_expected)

        self.assertEqual(response.status_code, 302)
        self.assertTrue(result_form.form_state, FormState.AUDIT)
        self.assertIsNone(result_form.audit)
        self.assertEqual(result_form.audited_count, 0)
        self.assertIn('archive/print', response['location'])
コード例 #8
0
ファイル: test_data_entry.py プロジェクト: onaio/tally-ho
 def test_center_detail_redirects_to_enter_results(self):
     self._create_and_login_user()
     self._add_user_to_group(self.user, groups.DATA_ENTRY_1_CLERK)
     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.DATA_ENTRY_1,
                                      center=center,
                                      tally=tally,
                                      station_number=station_number)
     view = views.CenterDetailsView.as_view()
     result_form_data = {'result_form': result_form.pk}
     data = center_data(code,
                        station_number=station_number,
                        tally_id=tally.pk)
     data.update(result_form_data)
     request = self.factory.post('/', data=data)
     request.user = self.user
     request.session = result_form_data
     response = view(request, tally_id=tally.pk)
     self.assertEqual(response.status_code, 302)
     self.assertIn('data-entry/enter-results',
                   response['location'])
コード例 #9
0
ファイル: test_data_entry.py プロジェクト: helioid/tally-ho
    def test_enter_results_success_data_entry_two(self):
        code = '12345'
        center = create_center(code)
        create_station(center)
        result_form = create_result_form(form_state=FormState.DATA_ENTRY_2,
                                         center=center)
        ballot = result_form.ballot
        candidate_name = 'candidate name'
        create_candidate(ballot, candidate_name)

        self._create_and_login_user()
        self._add_user_to_group(self.user, groups.DATA_ENTRY_2_CLERK)

        response = self._post_enter_results(result_form)

        self.assertEqual(response.status_code, 302)
        self.assertIn('data-entry', response['location'])
        updated_result_form = ResultForm.objects.get(pk=result_form.pk)
        self.assertEqual(updated_result_form.form_state, FormState.CORRECTION)

        reconciliation_forms = updated_result_form.reconciliationform_set.all()
        self.assertEqual(len(reconciliation_forms), 1)

        self.assertEqual(reconciliation_forms[0].entry_version,
                         EntryVersion.DATA_ENTRY_2)

        results = updated_result_form.results.all()
        self.assertEqual(len(results), 1)
        self.assertEqual(results[0].entry_version, EntryVersion.DATA_ENTRY_2)
        self.assertEqual(results[0].user, self.user)
コード例 #10
0
ファイル: test_data_entry.py プロジェクト: helioid/tally-ho
    def test_enter_results_success_data_entry_one(self):
        code = '12345'
        center = create_center(code)
        create_station(center)
        result_form = create_result_form(form_state=FormState.DATA_ENTRY_1,
                                         center=center)
        ballot = result_form.ballot
        candidate_name = 'candidate name'
        create_candidate(ballot, candidate_name)

        self._create_and_login_user()
        self._add_user_to_group(self.user, groups.DATA_ENTRY_1_CLERK)

        response = self._post_enter_results(result_form)

        self.assertEqual(response.status_code, 302)
        self.assertIn('data-entry', response['location'])
        result_form.reload()
        self.assertEqual(result_form.form_state, FormState.DATA_ENTRY_2)

        reconciliation_forms = result_form.reconciliationform_set.all()
        self.assertEqual(len(reconciliation_forms), 1)
        self.assertEqual(reconciliation_forms[0].entry_version,
                         EntryVersion.DATA_ENTRY_1)

        results = result_form.results.all()
        self.assertEqual(len(results), 1)
        self.assertEqual(results[0].entry_version, EntryVersion.DATA_ENTRY_1)

        for result in results:
            self.assertEqual(result.user, self.user)
コード例 #11
0
ファイル: test_archive.py プロジェクト: helioid/tally-ho
    def test_archive_post_quarantine_pass_below_tolerance(self):
        center = create_center()
        create_station(center)
        create_quarantine_checks()
        self._create_and_login_user()
        barcode = '123456789'
        result_form = create_result_form(form_state=FormState.ARCHIVING,
                                         center=center,
                                         station_number=1)
        recon_form = create_reconciliation_form(result_form,
                                                self.user,
                                                number_ballots_inside_box=21,
                                                number_unstamped_ballots=0)
        create_candidates(result_form, self.user, votes=1, num_results=10)
        self._add_user_to_group(self.user, groups.ARCHIVE_CLERK)
        view = views.ArchiveView.as_view()
        data = {'barcode': barcode, 'barcode_copy': barcode}
        request = self.factory.post('/', data=data)
        request.session = {}
        request.user = self.user
        response = view(request)
        result_form.reload()

        self.assertEqual(result_form.num_votes,
                         recon_form.number_ballots_expected)

        self.assertEqual(response.status_code, 302)
        self.assertTrue(result_form.form_state, FormState.AUDIT)
        self.assertTrue(result_form.audit)
        self.assertEqual(result_form.audit.quarantine_checks.count(), 1)
        self.assertEqual(result_form.audit.quarantine_checks.all()[0].name[:9],
                         'Trigger 1')
        self.assertEqual(result_form.audited_count, 1)
        self.assertIn('archive/print', response['location'])
コード例 #12
0
    def test_quality_control_post_quarantine(self):
        self._create_and_login_user()
        tally = create_tally()
        tally.users.add(self.user)
        center = create_center()
        create_station(center)
        create_quarantine_checks()
        result_form = create_result_form(
            form_state=FormState.QUALITY_CONTROL,
            tally=tally,
            center=center,
            station_number=1)
        create_reconciliation_form(
            result_form, self.user, number_unstamped_ballots=1000)
        create_quality_control(result_form, self.user)
        self._add_user_to_group(self.user, groups.QUALITY_CONTROL_CLERK)
        view = views.QualityControlDashboardView.as_view()
        data = {
            'correct': 1,
            'result_form': result_form.pk,
            'tally_id': tally.pk,
        }
        request = self.factory.post('/', data=data)
        request.session = {'result_form': result_form.pk}
        request.user = self.user
        response = view(request, tally_id=tally.pk)
        result_form.reload()

        self.assertEqual(response.status_code, 302)
        self.assertTrue(result_form.form_state, FormState.AUDIT)
        self.assertTrue(result_form.audit)
        self.assertEqual(result_form.audit.quarantine_checks.count(), 2)
        self.assertEqual(result_form.audit.user, self.user)
        self.assertEqual(result_form.audited_count, 1)
        self.assertIn('quality-control/print', response['location'])
コード例 #13
0
    def test_quality_control_post_quarantine(self):
        self._create_and_login_user()
        tally = create_tally()
        tally.users.add(self.user)
        center = create_center()
        create_station(center)
        create_quarantine_checks()
        result_form = create_result_form(form_state=FormState.QUALITY_CONTROL,
                                         tally=tally,
                                         center=center,
                                         station_number=1)
        create_reconciliation_form(result_form,
                                   self.user,
                                   number_unstamped_ballots=1000)
        create_quality_control(result_form, self.user)
        self._add_user_to_group(self.user, groups.QUALITY_CONTROL_CLERK)
        view = views.QualityControlDashboardView.as_view()
        data = {
            'correct': 1,
            'result_form': result_form.pk,
            'tally_id': tally.pk,
        }
        request = self.factory.post('/', data=data)
        request.session = {'result_form': result_form.pk}
        request.user = self.user
        response = view(request, tally_id=tally.pk)
        result_form.reload()

        self.assertEqual(response.status_code, 302)
        self.assertTrue(result_form.form_state, FormState.AUDIT)
        self.assertTrue(result_form.audit)
        self.assertEqual(result_form.audit.quarantine_checks.count(), 2)
        self.assertEqual(result_form.audit.user, self.user)
        self.assertEqual(result_form.audited_count, 1)
        self.assertIn('quality-control/print', response['location'])
コード例 #14
0
 def test_pass_overvote_true(self):
     center = create_center()
     create_station(center=center,
                    registrants=1)
     result_form = create_result_form(center=center)
     create_reconciliation_form(result_form, self.user)
     self.assertEqual(pass_overvote(result_form), True)
コード例 #15
0
 def test_center_detail_invalid_center(self):
     self._create_and_login_user()
     self._add_user_to_group(self.user, groups.DATA_ENTRY_1_CLERK)
     tally = create_tally()
     tally.users.add(self.user)
     code = '12345'
     other_code = '21345'
     station_number = 1
     center = create_center(code, tally=tally)
     other_center = create_center(other_code, tally=tally)
     create_station(center)
     create_station(other_center)
     result_form = create_result_form(form_state=FormState.DATA_ENTRY_1,
                                      center=center,
                                      tally=tally,
                                      station_number=station_number)
     view = views.CenterDetailsView.as_view()
     session = {'result_form': result_form.pk}
     data = center_data(other_code,
                        station_number=station_number,
                        tally_id=tally.pk)
     data.update(session)
     request = self.factory.post('/', data=data)
     request.user = self.user
     request.session = session
     response = view(request, tally_id=tally.pk)
     self.assertEqual(response.status_code, 200)
     response.render()
     self.assertContains(response,
                         'Center and station numbers do not match')
コード例 #16
0
ファイル: test_data_entry.py プロジェクト: ben12345/tally-ho
 def test_center_detail_invalid_center(self):
     code = '12345'
     other_code = '21345'
     station_number = 1
     center = create_center(code)
     other_center = create_center(other_code)
     create_station(center)
     create_station(other_center)
     result_form = create_result_form(form_state=FormState.DATA_ENTRY_1,
                                      center=center,
                                      station_number=station_number)
     self._create_and_login_user()
     self._add_user_to_group(self.user, groups.DATA_ENTRY_1_CLERK)
     view = views.CenterDetailsView.as_view()
     session = {'result_form': result_form.pk}
     data = center_data(other_code, station_number=station_number)
     data.update(session)
     request = self.factory.post('/', data=data)
     request.user = self.user
     request.session = session
     response = view(request)
     self.assertEqual(response.status_code, 200)
     response.render()
     self.assertContains(response,
                         'Center and station numbers do not match')
コード例 #17
0
ファイル: test_archive.py プロジェクト: comocho00/tally-ho
    def test_archive_post_quarantine_pass_below_tolerance(self):
        center = create_center()
        create_station(center)
        create_quarantine_checks()
        self._create_and_login_user()
        barcode = '123456789'
        result_form = create_result_form(
            form_state=FormState.ARCHIVING,
            center=center, station_number=1)
        recon_form = create_reconciliation_form(
            result_form, self.user, number_ballots_inside_box=21,
            number_unstamped_ballots=0)
        create_candidates(result_form, self.user, votes=1, num_results=10)
        self._add_user_to_group(self.user, groups.QUALITY_CONTROL_ARCHIVE_CLERK)
        view = views.ArchiveView.as_view()
        data = {'barcode': barcode, 'barcode_copy': barcode}
        request = self.factory.post('/', data=data)
        request.session = {}
        request.user = self.user
        response = view(request)
        result_form.reload()

        self.assertEqual(result_form.num_votes,
                         recon_form.number_ballots_expected)

        self.assertEqual(response.status_code, 302)
        self.assertTrue(result_form.form_state, FormState.AUDIT)
        self.assertTrue(result_form.audit)
        self.assertEqual(result_form.audit.quarantine_checks.count(), 1)
        self.assertEqual(
            result_form.audit.quarantine_checks.all()[0].name[:9], 'Trigger 1')
        self.assertEqual(result_form.audited_count, 1)
        self.assertIn('archive/print', response['location'])
コード例 #18
0
 def test_center_detail_center_alpha_numeric(self):
     self._create_and_login_user()
     self._add_user_to_group(self.user, groups.DATA_ENTRY_1_CLERK)
     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.DATA_ENTRY_1,
                                      center=center,
                                      tally=tally,
                                      station_number=station_number)
     view = views.CenterDetailsView.as_view()
     data = center_data('12345', '12346')
     data['center_number'] = 'abcde'
     data['center_number_copy'] = 'abcde'
     session = {'result_form': result_form.pk}
     data.update(session)
     request = self.factory.post('/', data=data)
     request.user = self.user
     request.session = session
     response = view(request, tally_id=tally.pk)
     self.assertContains(response,
                         u'Expecting only numbers for center number')
コード例 #19
0
ファイル: test_data_entry.py プロジェクト: ben12345/tally-ho
    def test_enter_results_success_data_entry_two(self):
        code = '12345'
        center = create_center(code)
        create_station(center)
        result_form = create_result_form(form_state=FormState.DATA_ENTRY_2,
                                         center=center)
        ballot = result_form.ballot
        candidate_name = 'candidate name'
        create_candidate(ballot, candidate_name)

        self._create_and_login_user()
        self._add_user_to_group(self.user, groups.DATA_ENTRY_2_CLERK)

        response = self._post_enter_results(result_form)

        self.assertEqual(response.status_code, 302)
        self.assertIn('data-entry',
                      response['location'])
        updated_result_form = ResultForm.objects.get(pk=result_form.pk)
        self.assertEqual(updated_result_form.form_state,
                         FormState.CORRECTION)

        reconciliation_forms = updated_result_form.reconciliationform_set.all()
        self.assertEqual(len(reconciliation_forms), 1)

        self.assertEqual(reconciliation_forms[0].entry_version,
                         EntryVersion.DATA_ENTRY_2)

        results = updated_result_form.results.all()
        self.assertEqual(len(results), 1)
        self.assertEqual(results[0].entry_version, EntryVersion.DATA_ENTRY_2)
        self.assertEqual(results[0].user, self.user)
コード例 #20
0
 def test_pass_tamper_true_no_recon(self):
     """Test pass tampering returns true with no recon form"""
     center = create_center()
     create_station(center=center,
                    registrants=1)
     result_form = create_result_form(center=center)
     self.assertEqual(pass_tampering(result_form), True)
コード例 #21
0
 def test_pass_overvote_true(self):
     """Test pass overvote returns true"""
     center = create_center()
     create_station(center=center,
                    registrants=1)
     result_form = create_result_form(center=center)
     create_reconciliation_form(result_form, self.user)
     self.assertEqual(pass_overvote(result_form), True)
コード例 #22
0
 def test_pass_tampering_true(self):
     center = create_center()
     create_station(center=center, registrants=1)
     result_form = create_result_form(center=center)
     create_reconciliation_form(result_form,
                                self.user,
                                number_unstamped_ballots=0)
     self.assertEqual(pass_tampering(result_form), True)
コード例 #23
0
 def test_pass_tampering_true(self):
     center = create_center()
     create_station(center=center,
                    registrants=1)
     result_form = create_result_form(center=center)
     create_reconciliation_form(result_form,
                                self.user,
                                number_unstamped_ballots=0)
     self.assertEqual(pass_tampering(result_form), True)
コード例 #24
0
 def test_pass_tampering_true_diff(self):
     """Test pass tampering returns true difference"""
     center = create_center()
     create_station(center=center,
                    registrants=1)
     result_form = create_result_form(center=center)
     create_candidates(result_form, self.user, num_results=1)
     create_reconciliation_form(result_form,
                                self.user,
                                number_ballots_inside_box=250,
                                number_unstamped_ballots=0)
     self.assertEqual(pass_tampering(result_form), True)
コード例 #25
0
    def setUp(self):
        self.factory = RequestFactory()
        self._create_permission_groups()
        self._create_and_login_user()
        self._add_user_to_group(self.user, groups.TALLY_MANAGER)
        self.tally = create_tally()
        self.tally.users.add(self.user)

        ballot = create_ballot(tally=self.tally)
        center = create_center('12345', tally=self.tally)
        station = create_station(center)
        result_form = create_result_form(tally=self.tally,
                                         ballot=ballot,
                                         center=center,
                                         station_number=station.station_number)
        votes = 12
        create_candidates(result_form,
                          votes=votes,
                          user=self.user,
                          num_results=1)
        for result in result_form.results.all():
            result.entry_version = EntryVersion.FINAL
            result.save()
            # create duplicate final results
            create_result(result_form, result.candidate, self.user, votes)
コード例 #26
0
    def test_dashboard_get_double_recon(self):
        self._create_and_login_user()
        tally = create_tally()
        tally.users.add(self.user)
        barcode = '123456789'
        center = create_center(tally=tally)
        station = create_station(center=center)
        result_form = create_result_form(barcode,
                                         center=center,
                                         station_number=station.station_number,
                                         tally=tally,
                                         form_state=FormState.QUALITY_CONTROL)
        create_reconciliation_form(result_form, self.user)
        create_reconciliation_form(result_form, self.user)
        create_candidates(result_form, self.user)
        create_quality_control(result_form, self.user)

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

        self.assertEqual(response.status_code, 200)
        self.assertContains(response, 'General Results Section')
        self.assertContains(response, 'Cancel')
コード例 #27
0
    def test_dashboard_get_double_recon_raise(self):
        self._create_and_login_user()
        tally = create_tally()
        tally.users.add(self.user)
        barcode = '123456789'
        center = create_center(tally=tally)
        station = create_station(center=center)
        result_form = create_result_form(barcode,
                                         center=center,
                                         station_number=station.station_number,
                                         tally=tally,
                                         form_state=FormState.QUALITY_CONTROL)
        create_reconciliation_form(result_form, self.user)
        create_reconciliation_form(result_form, self.user,
                                   ballot_number_from=2)
        create_candidates(result_form, self.user)
        create_quality_control(result_form, self.user)

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

        with self.assertRaises(SuspiciousOperation):
            view(request, tally_id=tally.pk)
コード例 #28
0
    def test_station_progress_list_data_view(self):
        """
        Test that station progress list data view returns correct data
        """
        tally = create_tally()
        tally.users.add(self.user)
        center = create_center(tally=tally)
        station = create_station(center=center, tally=tally)
        create_result_form(form_state=FormState.ARCHIVED,
                           tally=tally,
                           station_number=station.station_number)
        view = views.StationProgressListDataView.as_view()
        request = self.factory.get('/')
        request.user = self.user
        response = view(request, tally_id=tally.pk)

        office_name, sub_constituency_code, center_name, center_code,\
            station_number, gender, registrants, active = json.loads(
                response.content.decode())['data'][0]

        self.assertEquals(office_name, str(station.center.office.name))
        self.assertEquals(sub_constituency_code,
                          str(station.sub_constituency.code))
        self.assertEquals(office_name, str(station.center.office.name))
        self.assertEquals(center_name, str(station.center.name))
        self.assertEquals(center_code, str(station.center.code))
        self.assertEquals(station_number, str(station.station_number))
        self.assertEquals(gender, str(station.gender.name.capitalize()))
        self.assertEquals(registrants, str(station.registrants))
        self.assertEquals(active, str(station.active))
コード例 #29
0
    def test_women_get(self):
        barcode = "123456789"
        center = create_center()
        station = create_station(center=center)
        create_result_form(
            barcode, center=center, station_number=station.station_number, form_state=FormState.QUALITY_CONTROL
        )
        result_form = ResultForm.objects.get(barcode=barcode)
        self._create_and_login_user()
        name = "general candidate name"
        women_name = "women candidate name"
        votes = 123

        create_candidates(result_form, self.user, name, votes, women_name)

        self._add_user_to_group(self.user, groups.QUALITY_CONTROL_CLERK)
        view = views.QualityControlDashboardView.as_view()
        request = self.factory.get("/")
        request.user = self.user
        request.session = {"result_form": result_form.pk}
        response = view(request)
        response.render()
        self.assertEqual(response.status_code, 200)
        # gender has been removed
        # self.assertContains(response, str(result_form.gender_name))
        self.assertContains(response, "Women")
        self.assertContains(response, women_name)
        self.assertContains(response, name)
        self.assertContains(response, str(votes))
コード例 #30
0
ファイル: test_intake.py プロジェクト: onaio/tally-ho
 def test_duplicate_forms_post(self):
     self._create_or_login_intake_clerk()
     tally = create_tally()
     tally.users.add(self.user)
     center = create_center(tally=tally)
     station = create_station(center=center, tally=tally)
     result_form = create_result_form(tally=tally,
                                      center=center,
                                      station_number=station.station_number,
                                      form_state=FormState.DATA_ENTRY_1)
     result_form2 = create_result_form(
         '123456289',
         tally=tally,
         ballot=result_form.ballot,
         center=result_form.center,
         station_number=result_form.station_number,
         serial_number=3)
     view = views.CenterDetailsView.as_view()
     data = {
         'barcode': result_form2.barcode,
         'barcode_copy': result_form2.barcode,
         'tally_id': tally.pk,
     }
     request = self.factory.post('/', data=data)
     request.session = {}
     request.user = self.user
     response = view(request, tally_id=tally.pk)
     self.assertEqual(response.status_code, 302)
     self.assertEqual(request.session['intake-error'],
                      INTAKE_DUPLICATE_ERROR_MESSAGE)
コード例 #31
0
    def test_women_get(self):
        self._create_and_login_user()
        tally = create_tally()
        tally.users.add(self.user)
        barcode = '123456789'
        center = create_center()
        station = create_station(center=center)
        create_result_form(barcode,
                           center=center,
                           station_number=station.station_number,
                           tally=tally,
                           form_state=FormState.QUALITY_CONTROL)
        result_form = ResultForm.objects.get(barcode=barcode)
        name = 'general candidate name'
        women_name = 'women candidate name'
        votes = 123

        create_candidates(result_form, self.user, name, votes, women_name)

        self._add_user_to_group(self.user, groups.QUALITY_CONTROL_CLERK)
        view = views.QualityControlDashboardView.as_view()
        request = self.factory.get('/')
        request.user = self.user
        request.session = {'result_form': result_form.pk}
        response = view(request, tally_id=tally.pk)
        response.render()
        self.assertEqual(response.status_code, 200)
        self.assertContains(response, 'Women')
        self.assertContains(response, women_name)
        self.assertContains(response, name)
        self.assertContains(response, str(votes))
コード例 #32
0
    def test_dashboard_get(self):
        barcode = '123456789'
        self._create_and_login_user()
        center = create_center()
        station = create_station(center=center)
        create_result_form(barcode,
                           center=center,
                           station_number=station.station_number,
                           form_state=FormState.QUALITY_CONTROL)
        result_form = ResultForm.objects.get(barcode=barcode)
        create_candidates(result_form, self.user)
        create_quality_control(result_form, self.user)
        self._add_user_to_group(self.user, groups.QUALITY_CONTROL_ARCHIVE_CLERK)
        view = views.QualityControlDashboardView.as_view()
        request = self.factory.get('/')
        request.user = self.user
        request.session = {'result_form': result_form.pk}
        response = view(request)

        self.assertEqual(response.status_code, 200)
        # gender has been removed
        # self.assertContains(response, str(result_form.gender_name))
        self.assertContains(response, 'General Results Section')
        self.assertNotContains(response, 'Reconciliation')
        self.assertContains(response, 'Abort')
コード例 #33
0
ファイル: test_import_data.py プロジェクト: onaio/tally-ho
    def test_process_results_form_row_ballot_number_error(self):
        ballot = create_ballot(tally=self.tally)
        sc, _ = SubConstituency.objects.get_or_create(code=2, field_office='1')
        center = create_center(self.number,
                               tally=self.tally,
                               sub_constituency=sc)
        station = create_station(center)
        row = [
            str(ballot.number),
            center.code,
            str(station.station_number),
            self.gender,
            self.name,
            self.office_name,
            self.empty_string,
            self.barcode,
            self.serial_number]

        with self.assertLogs(logger=self.logger, level='WARNING') as cm:
            process_results_form_row(tally=self.tally,
                                     row=row,
                                     logger=self.logger)
            self.assertIn(
                str('WARNING:%s:Ballot number "%s" do not match for '
                    'center "%s" and station "%s"') %
                (self.logger.name,
                 ballot.number,
                 center.code,
                 station.station_number), cm.output)
コード例 #34
0
 def test_remove_result_form_confirmation_get(self):
     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.UNSUBMITTED,
                                      center=center,
                                      tally=tally,
                                      station_number=station_number)
     view = views.RemoveResultFormConfirmationView.as_view()
     request = self.factory.get('/')
     request.user = self.user
     response = view(request, form_id=result_form.pk, tally_id=tally.pk)
     self.assertContains(response, '<form name="remove-form-form"')
コード例 #35
0
 def test_create_result_form_valid(self):
     tally = create_tally()
     tally.users.add(self.user)
     code = '12345'
     barcode = '12345'
     ballot = create_ballot(tally=tally)
     sc, _ = SubConstituency.objects.get_or_create(code=1, field_office='1')
     center = create_center(code, tally=tally, sub_constituency=sc)
     station = create_station(center)
     form_data = {
         'center': center.pk,
         'station_number': station.station_number,
         'tally': tally.pk,
         'form_state': 9,
         'ballot': ballot.pk,
         'barcode': barcode,
         'created_user': self.request.user.userprofile,
         'gender': 1
     }
     form = CreateResultForm(form_data)
     self.assertTrue(form.is_valid())
     self.assertEqual(form.instance.barcode, barcode)
     form.save()
     self.assertEqual(
         ResultForm.objects.get(id=form.instance.id).barcode, barcode)
コード例 #36
0
 def test_disable_entity_view_post_station(self):
     tally = create_tally()
     tally.users.add(self.user)
     center = create_center(tally=tally)
     station = create_station(center)
     comment_text = 'example comment text'
     view = views.DisableEntityView.as_view()
     data = {
         'center_code_input': center.code,
         'station_number_input': station.station_number,
         'tally_id': tally.pk,
         'comment_input': comment_text,
         'disable_reason': '2',
     }
     request = self.factory.post('/', data)
     request.user = self.user
     response = view(request,
                     center_code=center.code,
                     station_number=station.station_number,
                     tally_id=tally.pk)
     self.assertEqual(response.status_code, 302)
     self.assertIn('/data/center-list/%s/' % tally.pk, response['Location'])
     station.reload()
     self.assertEqual(station.disable_reason.value, 2)
     self.assertEqual(station.comments.all()[0].text, comment_text)
コード例 #37
0
    def test_new_form_post(self):
        # save clearance as clerk
        self._create_and_login_user()
        self._add_user_to_group(self.user, groups.CLEARANCE_CLERK)
        tally = create_tally()
        tally.users.add(self.user)
        center = create_center(tally=tally)
        station = create_station(center)
        office = create_office(tally=tally)
        result_form = create_result_form(form_state=FormState.CLEARANCE,
                                         force_ballot=False,
                                         tally=tally,
                                         gender=Gender.MALE)
        ballot = create_ballot(tally=tally)
        view = CreateResultFormView.as_view(clearance_result_form=True)
        data = {
            'result_form': result_form.pk,
            'gender': [u'0'],
            'ballot': [ballot.pk],
            'center': [center.pk],
            'office': [office.pk],
            'tally_id': tally.id,
            'station_number': station.station_number,
        }
        request = self.factory.post('/', data=data)
        request.user = self.user
        request.session = {'result_form': result_form.pk}
        response = view(request, tally_id=tally.pk)
        result_form.reload()

        self.assertEqual(response.status_code, 200)
        self.assertEqual(result_form.gender, Gender.MALE)
コード例 #38
0
ファイル: test_clearance.py プロジェクト: onaio/tally-ho
    def test_new_form_post(self):
        # save clearance as clerk
        self._create_and_login_user()
        self._add_user_to_group(self.user, groups.CLEARANCE_CLERK)
        tally = create_tally()
        tally.users.add(self.user)
        center = create_center(tally=tally)
        station = create_station(center)
        office = create_office(tally=tally)
        result_form = create_result_form(
            form_state=FormState.CLEARANCE,
            force_ballot=False,
            tally=tally,
            gender=Gender.MALE)
        ballot = create_ballot(tally=tally)
        view = CreateResultFormView.as_view(clearance_result_form=True)
        data = {
            'result_form': result_form.pk,
            'gender': [u'0'],
            'ballot': [ballot.pk],
            'center': [center.pk],
            'office': [office.pk],
            'tally_id': tally.id,
            'station_number': station.station_number,
        }
        request = self.factory.post('/', data=data)
        request.user = self.user
        request.session = {'result_form': result_form.pk}
        response = view(request, tally_id=tally.pk)
        result_form.reload()

        self.assertEqual(response.status_code, 200)
        self.assertEqual(result_form.gender, Gender.MALE)
コード例 #39
0
 def test_duplicate_forms_post(self):
     self._create_or_login_intake_clerk()
     tally = create_tally()
     tally.users.add(self.user)
     center = create_center(tally=tally)
     station = create_station(center=center, tally=tally)
     result_form = create_result_form(tally=tally,
                                      center=center,
                                      station_number=station.station_number,
                                      form_state=FormState.DATA_ENTRY_1)
     result_form2 = create_result_form(
         '123456289',
         tally=tally,
         ballot=result_form.ballot,
         center=result_form.center,
         station_number=result_form.station_number,
         serial_number=3)
     view = views.CenterDetailsView.as_view()
     data = {
         'barcode': result_form2.barcode,
         'barcode_copy': result_form2.barcode,
         'tally_id': tally.pk,
     }
     request = self.factory.post('/', data=data)
     request.session = {}
     request.user = self.user
     response = view(request, tally_id=tally.pk)
     self.assertEqual(response.status_code, 302)
     self.assertEqual(request.session['intake-error'],
                      INTAKE_DUPLICATE_ERROR_MESSAGE)
コード例 #40
0
    def test_dashboard_get_double_recon_raise(self):
        self._create_and_login_user()
        tally = create_tally()
        tally.users.add(self.user)
        barcode = '123456789'
        center = create_center(tally=tally)
        station = create_station(center=center)
        result_form = create_result_form(barcode,
                                         center=center,
                                         station_number=station.station_number,
                                         tally=tally,
                                         form_state=FormState.QUALITY_CONTROL)
        create_reconciliation_form(result_form, self.user)
        create_reconciliation_form(result_form,
                                   self.user,
                                   ballot_number_from=2)
        create_candidates(result_form, self.user)
        create_quality_control(result_form, self.user)

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

        with self.assertRaises(SuspiciousOperation):
            view(request, tally_id=tally.pk)
コード例 #41
0
    def test_general_get(self):
        barcode = '123456789'
        center = create_center()
        station = create_station(center=center)
        create_result_form(barcode,
                           center=center,
                           station_number=station.station_number,
                           form_state=FormState.QUALITY_CONTROL)
        result_form = ResultForm.objects.get(barcode=barcode)
        self._create_and_login_user()
        name = 'the candidate name'
        women_name = 'women candidate name'
        votes = 123

        create_candidates(result_form, self.user, name, votes, women_name)

        self._add_user_to_group(self.user,
                                groups.QUALITY_CONTROL_ARCHIVE_CLERK)
        view = views.QualityControlDashboardView.as_view()
        request = self.factory.get('/')
        request.user = self.user
        request.session = {'result_form': result_form.pk}
        response = view(request)
        response.render()
        self.assertEqual(response.status_code, 200)
        # gender has been removed
        # self.assertContains(response, str(result_form.gender_name))
        self.assertContains(response, 'General')
        self.assertContains(response, name)
        self.assertContains(response, women_name)
        self.assertContains(response, str(votes))
コード例 #42
0
    def test_dashboard_get(self):
        barcode = '123456789'
        self._create_and_login_user()
        tally = create_tally()
        tally.users.add(self.user)
        center = create_center(tally=tally)
        station = create_station(center=center)
        create_result_form(barcode,
                           center=center,
                           station_number=station.station_number,
                           tally=tally,
                           form_state=FormState.QUALITY_CONTROL)
        result_form = ResultForm.objects.get(barcode=barcode)
        create_candidates(result_form, self.user)
        create_quality_control(result_form, self.user)
        self._add_user_to_group(self.user, groups.QUALITY_CONTROL_CLERK)
        view = views.QualityControlDashboardView.as_view()
        request = self.factory.get('/')
        request.user = self.user
        request.session = {'result_form': result_form.pk}
        response = view(request, tally_id=tally.pk)

        self.assertEqual(response.status_code, 200)
        # gender has been removed
        # self.assertContains(response, str(result_form.gender_name))
        self.assertContains(response, 'General Results Section')
        self.assertNotContains(response, 'Reconciliation')
        self.assertContains(response, 'Cancel')
コード例 #43
0
    def test_women_get(self):
        self._create_and_login_user()
        tally = create_tally()
        tally.users.add(self.user)
        barcode = '123456789'
        center = create_center()
        station = create_station(center=center)
        create_result_form(barcode,
                           center=center,
                           station_number=station.station_number,
                           tally=tally,
                           form_state=FormState.QUALITY_CONTROL)
        result_form = ResultForm.objects.get(barcode=barcode)
        name = 'general candidate name'
        women_name = 'women candidate name'
        votes = 123

        create_candidates(result_form, self.user, name, votes, women_name)

        self._add_user_to_group(self.user, groups.QUALITY_CONTROL_CLERK)
        view = views.QualityControlDashboardView.as_view()
        request = self.factory.get('/')
        request.user = self.user
        request.session = {'result_form': result_form.pk}
        response = view(request, tally_id=tally.pk)
        response.render()
        self.assertEqual(response.status_code, 200)
        self.assertContains(response, 'Women')
        self.assertContains(response, women_name)
        self.assertContains(response, name)
        self.assertContains(response, str(votes))
コード例 #44
0
    def test_dashboard_get_double_recon(self):
        barcode = '123456789'
        self._create_and_login_user()
        center = create_center()
        station = create_station(center=center)
        result_form = create_result_form(barcode,
                                         center=center,
                                         station_number=station.station_number,
                                         form_state=FormState.QUALITY_CONTROL)
        create_reconciliation_form(result_form, self.user)
        create_reconciliation_form(result_form, self.user)
        create_candidates(result_form, self.user)
        create_quality_control(result_form, self.user)

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

        self.assertEqual(response.status_code, 200)
        self.assertContains(response, 'General Results Section')
        self.assertContains(response, 'Abort')
コード例 #45
0
ファイル: test_import_data.py プロジェクト: onaio/tally-ho
    def test_process_results_form_row_office_name_error(self):
        ballot = create_ballot(tally=self.tally)
        sc, _ = SubConstituency.objects.get_or_create(code=1, field_office='1')
        center = create_center(self.number,
                               tally=self.tally,
                               sub_constituency=sc)
        station = create_station(center)
        office_name = 'Mombasa'
        row = [
            str(ballot.number),
            center.code,
            str(station.station_number),
            self.gender,
            self.name,
            office_name,
            self.empty_string,
            self.barcode,
            self.serial_number]

        with self.assertLogs(logger=self.logger, level='WARNING') as cm:
            process_results_form_row(tally=self.tally,
                                     row=row,
                                     logger=self.logger)
            self.assertIn(str('WARNING:%s:Office "%s" does not exist') %
                          (self.logger.name, office_name), cm.output)
コード例 #46
0
ファイル: test_data_entry.py プロジェクト: onaio/tally-ho
    def test_enter_results_success_data_entry(self):
        self._create_and_login_user('data_entry_1')
        self._add_user_to_group(self.user, groups.DATA_ENTRY_1_CLERK)
        tally = create_tally()
        tally.users.add(self.user)
        code = '12345'
        center = create_center(code, tally=tally)
        create_station(center)
        result_form = create_result_form(form_state=FormState.DATA_ENTRY_1,
                                         tally=tally)
        ballot = result_form.ballot
        candidate_name = 'candidate name'
        create_candidate(ballot, candidate_name)

        view = views.EnterResultsView.as_view()
        data = result_form_data(result_form)
        request = self.factory.post('/', data=data)
        request.user = self.user
        request.session = {'result_form': result_form.pk}
        response = view(request, tally_id=tally.pk)

        data_entry_1 = self.user

        self._create_and_login_user('data_entry_2')
        self._add_user_to_group(self.user, groups.DATA_ENTRY_2_CLERK)
        tally.users.add(self.user)
        request.user = self.user
        response = view(request, tally_id=tally.pk)
        self.assertEqual(response.status_code, 302)
        self.assertIn('data-entry',
                      response['location'])
        updated_result_form = ResultForm.objects.get(pk=result_form.pk)
        self.assertEqual(updated_result_form.form_state,
                         FormState.CORRECTION)
        results = updated_result_form.results.filter(
            entry_version=EntryVersion.DATA_ENTRY_2)
        self.assertTrue(results.count() > 0)
        self.assertEqual(results.all()[0].user, self.user)
        results = updated_result_form.results.filter(
            entry_version=EntryVersion.DATA_ENTRY_2)
        self.assertTrue(results.count() > 0)

        for result in results:
            self.assertEqual(result.user, self.user)
            self.assertNotEqual(result.user, data_entry_1)
コード例 #47
0
    def test_enter_results_success_data_entry(self):
        self._create_and_login_user('data_entry_1')
        self._add_user_to_group(self.user, groups.DATA_ENTRY_1_CLERK)
        tally = create_tally()
        tally.users.add(self.user)
        code = '12345'
        center = create_center(code, tally=tally)
        create_station(center)
        result_form = create_result_form(form_state=FormState.DATA_ENTRY_1,
                                         tally=tally)
        ballot = result_form.ballot
        candidate_name = 'candidate name'
        create_candidate(ballot, candidate_name)

        view = views.EnterResultsView.as_view()
        data = result_form_data(result_form)
        request = self.factory.post('/', data=data)
        request.user = self.user
        request.session = {'result_form': result_form.pk}
        response = view(request, tally_id=tally.pk)

        data_entry_1 = self.user

        self._create_and_login_user('data_entry_2')
        self._add_user_to_group(self.user, groups.DATA_ENTRY_2_CLERK)
        tally.users.add(self.user)
        request.user = self.user
        response = view(request, tally_id=tally.pk)
        self.assertEqual(response.status_code, 302)
        self.assertIn('data-entry',
                      response['location'])
        updated_result_form = ResultForm.objects.get(pk=result_form.pk)
        self.assertEqual(updated_result_form.form_state,
                         FormState.CORRECTION)
        results = updated_result_form.results.filter(
            entry_version=EntryVersion.DATA_ENTRY_2)
        self.assertTrue(results.count() > 0)
        self.assertEqual(results.all()[0].user, self.user)
        results = updated_result_form.results.filter(
            entry_version=EntryVersion.DATA_ENTRY_2)
        self.assertTrue(results.count() > 0)

        for result in results:
            self.assertEqual(result.user, self.user)
            self.assertNotEqual(result.user, data_entry_1)
コード例 #48
0
 def test_pass_overvote_false(self):
     center = create_center()
     station = create_station(center=center, registrants=1)
     result_form = create_result_form(center=center,
                                      station_number=station.station_number)
     create_reconciliation_form(result_form,
                                self.user,
                                number_unstamped_ballots=11)
     self.assertEqual(pass_overvote(result_form), False)
コード例 #49
0
    def test_print_success_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.QUALITY_CONTROL,
                                         center=center,
                                         station_number=station_number)
        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)

        self.assertEqual(response.status_code, 200)
        self.assertContains(response, 'Successful Archive')
コード例 #50
0
ファイル: test_archive.py プロジェクト: ben12345/tally-ho
    def test_print_success_get_supervisor(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.ARCHIVED,
                                         center=center,
                                         station_number=station_number)
        self._add_user_to_group(self.user, groups.ARCHIVE_SUPERVISOR)
        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, 'Successful Archive')
コード例 #51
0
 def test_remove_result_form_confirmation_post(self):
     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.UNSUBMITTED,
                                      center=center,
                                      tally=tally,
                                      station_number=station_number)
     view = views.RemoveResultFormConfirmationView.as_view()
     data = {'result_form': result_form.pk}
     request = self.factory.post('/', data=data)
     request.user = self.user
     request.session = {'result_form': result_form.pk}
     response = view(request, form_id=result_form.pk, tally_id=tally.pk)
     self.assertEqual(response.status_code, 302)
コード例 #52
0
ファイル: test_data_entry.py プロジェクト: ben12345/tally-ho
    def test_enter_results_invalid(self):
        code = '12345'
        center = create_center(code)
        create_station(center)
        result_form = create_result_form(form_state=FormState.DATA_ENTRY_1)
        ballot = result_form.ballot
        candidate_name = 'candidate name'
        create_candidate(ballot, candidate_name)

        self._create_and_login_user()
        self._add_user_to_group(self.user, groups.DATA_ENTRY_1_CLERK)
        view = views.EnterResultsView.as_view()
        data = result_form_data_blank(result_form)
        request = self.factory.post('/', data=data)
        request.user = self.user
        request.session = {'result_form': result_form.pk}
        response = view(request)
        self.assertEqual(response.status_code, 200)
        self.assertContains(response, 'Missing votes')
コード例 #53
0
 def test_enter_center_post_valid(self):
     center = create_center(code='11111')
     create_station(center)
     result_form = create_result_form(form_state=FormState.INTAKE)
     self._create_and_login_user()
     self._add_user_to_group(self.user, groups.INTAKE_CLERK)
     view = views.EnterCenterView.as_view()
     data = {'result_form': result_form.pk,
             'center_number': center.code,
             'center_number_copy': center.code,
             'station_number': 1,
             'station_number_copy': 1}
     request = self.factory.post('/',
                                 data=data)
     request.user = self.user
     request.session = {'result_form': result_form.pk}
     response = view(request)
     self.assertEqual(response.status_code, 302)
     self.assertIn('/intake/check-center-details', response['location'])
コード例 #54
0
 def test_pass_overvote_false(self):
     center = create_center()
     station = create_station(center=center, registrants=1)
     result_form = create_result_form(
         center=center,
         station_number=station.station_number)
     create_reconciliation_form(result_form,
                                self.user,
                                number_unstamped_ballots=11)
     self.assertEqual(pass_overvote(result_form), False)
コード例 #55
0
ファイル: test_data_entry.py プロジェクト: ben12345/tally-ho
 def test_center_detail_validates_clerk(self):
     code = '12345'
     station_number = 1
     center = create_center(code)
     create_station(center)
     result_form = create_result_form(form_state=FormState.DATA_ENTRY_2,
                                      center=center,
                                      station_number=station_number)
     self._create_and_login_user()
     self._add_user_to_group(self.user, groups.DATA_ENTRY_1_CLERK)
     view = views.CenterDetailsView.as_view()
     result_form_data = {'result_form': result_form.pk}
     data = center_data(code, station_number=station_number)
     data.update(result_form_data)
     request = self.factory.post('/', data=data)
     request.user = self.user
     request.session = result_form_data
     response = view(request)
     self.assertEqual(response.status_code, 200)
     self.assertContains(response, 'Data Entry 2')
コード例 #56
0
ファイル: test_data_entry.py プロジェクト: ben12345/tally-ho
    def test_center_detail_center_number_length(self):
        code = '12345'
        station_number = 1
        center = create_center(code)
        create_station(center)
        result_form = create_result_form(form_state=FormState.DATA_ENTRY_1,
                                         center=center,
                                         station_number=station_number)
        self._create_and_login_user()
        self._add_user_to_group(self.user, groups.DATA_ENTRY_1_CLERK)
        view = views.CenterDetailsView.as_view()
        data = {'center_number': '1234', 'center_number': '1234'}
        session = {'result_form': result_form.pk}
        data.update(session)
        request = self.factory.post('/', data=data)
        request.user = self.user
        request.session = session
        response = view(request)

        self.assertContains(response,
                            u'Ensure this value has at least 5 characters')
コード例 #57
0
ファイル: test_data_entry.py プロジェクト: ben12345/tally-ho
 def test_center_detail_no_station(self):
     code = '12345'
     station_number = 1
     center = create_center(code)
     create_station(center)
     result_form = create_result_form(form_state=FormState.DATA_ENTRY_1,
                                      center=center,
                                      station_number=station_number)
     self._create_and_login_user()
     self._add_user_to_group(self.user, groups.DATA_ENTRY_1_CLERK)
     view = views.CenterDetailsView.as_view()
     session = {'result_form': result_form.pk}
     data = center_data(code)
     data.update(session)
     data.update({'station_number': 3, 'station_number_copy': 3})
     request = self.factory.post('/', data=data)
     request.user = self.user
     request.session = session
     response = view(request)
     self.assertEqual(response.status_code, 200)
     self.assertContains(response, 'Invalid Station Number for this Center')
コード例 #58
0
    def test_quality_control_post_quarantine_pass_below_tolerance(self):
        center = create_center()
        create_station(center)
        create_quarantine_checks()
        self._create_and_login_user()
        tally = create_tally()
        tally.users.add(self.user)
        result_form = create_result_form(
            tally=tally,
            form_state=FormState.QUALITY_CONTROL,
            center=center, station_number=1)
        recon_form = create_reconciliation_form(
            result_form, self.user, number_ballots_inside_box=21,
            number_unstamped_ballots=0)
        create_quality_control(result_form, self.user)
        create_candidates(result_form, self.user, votes=1, num_results=10)
        self._add_user_to_group(self.user, groups.QUALITY_CONTROL_CLERK)
        view = views.QualityControlDashboardView.as_view()
        data = {
            'correct': 1,
            'result_form': result_form.pk,
            'tally_id': tally.pk,
        }
        request = self.factory.post('/', data=data)
        request.session = {'result_form': result_form.pk}
        request.user = self.user
        response = view(request, tally_id=tally.pk)
        result_form.reload()

        self.assertEqual(result_form.num_votes,
                         recon_form.number_ballots_expected)

        self.assertEqual(response.status_code, 302)
        self.assertTrue(result_form.form_state, FormState.AUDIT)
        self.assertTrue(result_form.audit)
        self.assertEqual(result_form.audit.quarantine_checks.count(), 1)
        self.assertEqual(
            result_form.audit.quarantine_checks.all()[0].name[:9], 'Trigger 1')
        self.assertEqual(result_form.audited_count, 1)
        self.assertIn('quality-control/print', response['location'])
コード例 #59
0
ファイル: test_data_entry.py プロジェクト: onaio/tally-ho
 def test_center_detail_center_not_equal(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.DATA_ENTRY_1,
                                      center=center,
                                      tally=tally,
                                      station_number=station_number)
     self._add_user_to_group(self.user, groups.DATA_ENTRY_1_CLERK)
     view = views.CenterDetailsView.as_view()
     data = center_data('12345', '12346')
     session = {'result_form': result_form.pk}
     data.update(session)
     request = self.factory.post('/', data=data)
     request.user = self.user
     request.session = session
     response = view(request, tally_id=tally.pk)
     self.assertContains(response, 'Center Numbers do not match')