本文整理汇总了Python中tally_ho.libs.tests.test_base.create_station函数的典型用法代码示例。如果您正苦于以下问题:Python create_station函数的具体用法?Python create_station怎么用?Python create_station使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了create_station函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_enter_results_success_data_entry_one
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)
示例2: test_center_detail_center_alpha_numeric
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')
示例3: test_center_detail_invalid_center
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')
示例4: test_archive_post_quarantine_pass_with_zero_diff
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'])
示例5: test_pass_overvote_true
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)
示例6: test_center_detail_redirects_to_enter_results
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'])
示例7: test_quality_control_post_quarantine
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'])
示例8: test_archive_post_quarantine_pass_below_tolerance
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'])
示例9: test_enter_results_success_data_entry_two
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: test_print_quarantine_get
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')
示例11: test_pass_tampering_true
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)
示例12: test_duplicate_forms_post
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)
示例13: test_process_results_form_row_ballot_number_error
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)
示例14: test_dashboard_get_double_recon_raise
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)
示例15: test_new_form_post
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)