def test_archive_post_quarantine(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) create_reconciliation_form( result_form, self.user, number_unstamped_ballots=1000) 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(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('archive/print', response['location'])
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'])
def test_archive_post_quarantine(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) create_reconciliation_form(result_form, self.user, number_unstamped_ballots=1000) 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(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('archive/print', response['location'])
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)
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'])
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'])
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)
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')
def test_review_post_check_audit_state_when_no_action_prior(self): self._create_and_login_user(username='******') self._add_user_to_group(self.user, groups.AUDIT_SUPERVISOR) tally = create_tally() tally.users.add(self.user) result_form = create_result_form(form_state=FormState.AUDIT, tally=tally) create_reconciliation_form(result_form, self.user) create_candidates(result_form, self.user) view = views.ReviewView.as_view() data = { 'result_form': result_form.pk, 'resolution_recommendation': 1, 'implement': 1, '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 = Audit.objects.get(result_form=result_form) self.assertEqual(audit.reviewed_supervisor, True) self.assertNotEqual(audit.result_form.form_state, FormState.AUDIT) self.assertEqual(audit.result_form.form_state, FormState.DATA_ENTRY_1)
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)
def test_reconciliation_match(self): result_form = create_result_form() create_reconciliation_form(result_form, self.user) re_form = create_reconciliation_form(result_form, self.user) re_form.entry_version = EntryVersion.DATA_ENTRY_2 re_form.save() self.assertTrue(result_form.reconciliation_match)
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)
def test_recon_post(self): view = views.CorrectionRequiredView.as_view() result_form = create_result_form(form_state=FormState.CORRECTION, tally=self.tally) create_results(result_form, vote1=2, vote2=2, race_type=RaceType.WOMEN) ballot_from_val = '2' sorted_counted_val = 3 is_stamped = False recon1 = create_reconciliation_form(result_form, self.user) recon1.entry_version = EntryVersion.DATA_ENTRY_1 recon1.save() recon2 = create_reconciliation_form( result_form, self.user, ballot_number_from=ballot_from_val, number_sorted_and_counted=sorted_counted_val, is_stamped=is_stamped) recon2.entry_version = EntryVersion.DATA_ENTRY_2 recon2.save() self._add_user_to_group(self.user, groups.CORRECTIONS_CLERK) self.assertEqual(ReconciliationForm.objects.filter( result_form=result_form).count(), 2) session = {'result_form': result_form.pk} data = { 'submit_corrections': 1, 'ballot_number_from': ballot_from_val, 'number_sorted_and_counted': sorted_counted_val, 'is_stamped': is_stamped, 'tally_id': self.tally.pk, } data.update(session) request = self.factory.post('/', data=data) request.session = session request.user = self.user response = view(request, tally_id=self.tally.pk) final_form = ReconciliationForm.objects.filter( result_form=result_form, entry_version=EntryVersion.FINAL)[0] self.assertEqual(final_form.ballot_number_from, ballot_from_val) self.assertEqual(final_form.is_stamped, is_stamped) self.assertEqual(final_form.number_sorted_and_counted, sorted_counted_val) self.assertEqual(final_form.result_form, result_form) self.assertEqual(final_form.entry_version, EntryVersion.FINAL) self.assertEqual(final_form.user, self.user) self.assertEqual(response.status_code, 302) updated_result_form = ResultForm.objects.get(pk=result_form.pk) self.assertEqual(updated_result_form.form_state, FormState.QUALITY_CONTROL) self.assertIn('corrections/success', response['location'])
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)
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)
def test_review_post_supervisor_implement_de1(self): # save audit as clerk self._create_and_login_user() 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) 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, 'forward': 1 } request = self.factory.post('/', data=data) request.user = self.user request.session = data response = view(request) # save as supervisor self._create_and_login_user(username='******') self._add_user_to_group(self.user, groups.AUDIT_SUPERVISOR) view = views.ReviewView.as_view() data = { 'result_form': result_form.pk, 'action_prior_to_recommendation': 1, 'resolution_recommendation': 1, 'implement': 1 } request = self.factory.post('/', data=data) request.user = self.user request.session = data response = view(request) audit = Audit.objects.get(result_form=result_form) self.assertEqual(audit.supervisor, self.user) self.assertTrue(audit.reviewed_supervisor) self.assertTrue(audit.reviewed_team) self.assertFalse(audit.active) self.assertEqual(audit.result_form.form_state, FormState.DATA_ENTRY_1) self.assertEqual(len(audit.result_form.results.all()), 20) self.assertEqual(len(audit.result_form.reconciliationform_set.all()), 2) for result in audit.result_form.results.all(): self.assertFalse(result.active) for result in audit.result_form.reconciliationform_set.all(): self.assertFalse(result.active) self.assertEqual(audit.action_prior_to_recommendation, 1) self.assertEqual(response.status_code, 302)
def test_valid_votes_per_office(self): """ Test that valid votes per office are returned """ result_form = ResultForm.objects.get( form_state=FormState.QUALITY_CONTROL) create_reconciliation_form(result_form, self.user) report = progress.ValidVotesProgressReport(self.tally.id) valid_votes = report.for_center_office( self.center.office, query_valid_votes=True) self.assertEqual(valid_votes, 1)
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)
def test_review_post_supervisor_implement_de1(self): # save audit as clerk self._create_and_login_user() 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) 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, 'forward': 1} request = self.factory.post('/', data=data) request.user = self.user request.session = data response = view(request) # save as supervisor self._create_and_login_user(username='******') self._add_user_to_group(self.user, groups.AUDIT_SUPERVISOR) view = views.ReviewView.as_view() data = {'result_form': result_form.pk, 'action_prior_to_recommendation': 1, 'resolution_recommendation': 1, 'implement': 1} request = self.factory.post('/', data=data) request.user = self.user request.session = data response = view(request) audit = Audit.objects.get(result_form=result_form) self.assertEqual(audit.supervisor, self.user) self.assertTrue(audit.reviewed_supervisor) self.assertTrue(audit.reviewed_team) self.assertFalse(audit.active) self.assertEqual(audit.result_form.form_state, FormState.AUDIT_PENDING_STATE) self.assertEqual(len(audit.result_form.results.all()), 20) self.assertEqual(len(audit.result_form.reconciliationform_set.all()), 2) for result in audit.result_form.results.all(): self.assertFalse(result.active) for result in audit.result_form.reconciliationform_set.all(): self.assertFalse(result.active) self.assertEqual(audit.action_prior_to_recommendation, 1) self.assertEqual(response.status_code, 302)
def test_remove_center_post_result_exists(self): center = create_center('12345') result_form = create_result_form(center=center, form_state=FormState.AUDIT) create_reconciliation_form(result_form, self.user) create_reconciliation_form(result_form, self.user) create_candidates(result_form, self.user) self.assertTrue(Result.objects.filter().count() > 0) view = views.RemoveCenterView.as_view() data = {'center_number': center.code} request = self.factory.post('/', data) request.user = self.user response = view(request) self.assertContains(response, u"Results exist for barcodes") self.assertContains(response, result_form.barcode)
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'])
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'])
def test_reconciliation_get(self): barcode = "123456789" create_result_form(barcode, form_state=FormState.QUALITY_CONTROL) result_form = ResultForm.objects.get(barcode=barcode) self._create_and_login_user() create_reconciliation_form(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) response.render() self.assertEqual(response.status_code, 200) self.assertContains(response, "Reconciliation") self.assertContains(response, "Total number of the sorted and counted")
def test_reconciliation_get(self): barcode = '123456789' create_result_form(barcode, form_state=FormState.QUALITY_CONTROL) result_form = ResultForm.objects.get(barcode=barcode) self._create_and_login_user() create_reconciliation_form(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) response.render() self.assertEqual(response.status_code, 200) self.assertContains(response, 'Reconciliation') self.assertContains(response, 'Total number of the sorted and counted')
def test_reconciliation_get(self): barcode = '123456789' self._create_and_login_user() tally = create_tally() tally.users.add(self.user) create_result_form(barcode, form_state=FormState.QUALITY_CONTROL, tally=tally) result_form = ResultForm.objects.get(barcode=barcode) create_reconciliation_form(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) response.render() self.assertEqual(response.status_code, 200) self.assertContains(response, 'Reconciliation') self.assertContains(response, 'Total number of the sorted and counted')
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_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")
def test_number_ballots_used_results(self): expected_votes = 0 for num_results in xrange(1, 4): for votes in xrange(1, 4): result_form = create_result_form() create_candidates(result_form, self.user, votes=votes, num_results=num_results) re_form = create_reconciliation_form(result_form, self.user) expected_votes += num_results * votes * 2 self.assertEqual(re_form.number_ballots_used, self.num_used + expected_votes)
def test_remove_station_post_result_exists(self): tally = create_tally() tally.users.add(self.user) center = create_center('12345', tally=tally) station = create_station(center) result_form = create_result_form(center=center, form_state=FormState.AUDIT, station_number=station.station_number) create_reconciliation_form(result_form, self.user) create_reconciliation_form(result_form, self.user) create_candidates(result_form, self.user) self.assertTrue(Result.objects.filter().count() > 0) view = views.RemoveStationView.as_view() data = { 'center_number': center.code, 'station_number': station.station_number, 'tally_id': tally.pk, } request = self.factory.post('/', data) request.user = self.user response = view(request, tally_id=tally.pk) self.assertContains(response, u"Results exist for barcodes") self.assertContains(response, result_form.barcode)
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'])
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'])
def test_number_ballots_used_no_results(self): result_form = create_result_form() re_form = create_reconciliation_form(result_form, self.user) self.assertEqual(re_form.number_ballots_used, self.num_used)
def test_review_post_supervisor_implement_de1(self): # save audit as clerk self._create_and_login_user() self._add_user_to_group(self.user, groups.AUDIT_CLERK) tally = create_tally() tally.users.add(self.user) result_form = create_result_form(form_state=FormState.AUDIT, tally=tally) create_reconciliation_form(result_form, self.user) create_reconciliation_form(result_form, self.user) create_candidates(result_form, self.user) view = views.ReviewView.as_view() data = { 'result_form': result_form.pk, 'action_prior_to_recommendation': 1, 'resolution_recommendation': 0, 'forward': 1, 'tally_id': tally.pk, } request = self.factory.post('/', data=data) request.user = self.user request.session = data response = view(request, tally_id=tally.pk) # save as supervisor self._create_and_login_user(username='******') self._add_user_to_group(self.user, groups.AUDIT_SUPERVISOR) tally.users.add(self.user) view = views.ReviewView.as_view() data = { 'result_form': result_form.pk, 'action_prior_to_recommendation': 1, 'resolution_recommendation': 1, 'implement': 1, 'tally_id': tally.pk, } request = self.factory.post('/', data=data) request.user = self.user data['encoded_result_form_audit_start_time'] =\ self.encoded_result_form_audit_start_time request.session = data response = view(request, tally_id=tally.pk) self.assertEqual(response.status_code, 302) audit = Audit.objects.get(result_form=result_form) self.assertEqual(audit.supervisor, self.user) self.assertTrue(audit.reviewed_supervisor) self.assertTrue(audit.reviewed_team) self.assertFalse(audit.active) self.assertEqual(audit.result_form.form_state, FormState.AUDIT) self.assertEqual(len(audit.result_form.results.all()), 20) self.assertEqual(len(audit.result_form.reconciliationform_set.all()), 2) result_form_stat = ResultFormStats.objects.get(result_form=result_form) approved_by_supervisor =\ audit.for_superadmin and audit.active self.assertEqual(result_form_stat.approved_by_supervisor, approved_by_supervisor) self.assertEqual(result_form_stat.reviewed_by_supervisor, audit.reviewed_supervisor) self.assertEqual(result_form_stat.user, self.user) self.assertEqual(result_form_stat.result_form, result_form) for result in audit.result_form.results.all(): self.assertFalse(result.active) for result in audit.result_form.reconciliationform_set.all(): self.assertFalse(result.active) self.assertEqual(audit.action_prior_to_recommendation, ActionsPrior.REQUEST_AUDIT_ACTION_FROM_FIELD)
def test_number_ballots_used_no_results(self): """Test number of ballots used with no results""" result_form = create_result_form() re_form = create_reconciliation_form(result_form, self.user) self.assertEqual(re_form.number_ballots_used, self.num_used)