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_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_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'])
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'])
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_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_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 setUp(self): create_quarantine_checks() self._create_permission_groups() self._create_and_login_user()
def handle(self, *args, **kwargs): create_quarantine_checks()