本文整理汇总了Python中tally_ho.libs.tests.test_base.create_result_form函数的典型用法代码示例。如果您正苦于以下问题:Python create_result_form函数的具体用法?Python create_result_form怎么用?Python create_result_form使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了create_result_form函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_women_post_incorrect_ballot_released
def test_women_post_incorrect_ballot_released(self):
self._create_and_login_user()
tally = create_tally()
tally.users.add(self.user)
barcode = '123456789'
ballot = create_ballot(available_for_release=True)
create_result_form(barcode,
tally=tally,
ballot=ballot,
form_state=FormState.QUALITY_CONTROL)
result_form = ResultForm.objects.get(barcode=barcode)
create_quality_control(result_form, self.user)
create_candidates(result_form, self.user)
self._add_user_to_group(self.user, groups.QUALITY_CONTROL_CLERK)
view = views.QualityControlDashboardView.as_view()
data = {
'result_form': result_form.pk,
'incorrect': 1,
'tally_id': tally.pk,
}
request = self.factory.post('/', data=data)
request.user = self.user
request.session = {'result_form': result_form.pk}
response = view(request, tally_id=tally.pk)
self.assertEqual(response.status_code, 302)
self.assertIn('quality-control/confirm-reject',
response['location'])
result_form = ResultForm.objects.get(pk=result_form.pk)
quality_control = result_form.qualitycontrol_set.all()[0]
self.assertTrue(quality_control.active)
self.assertEqual(result_form.form_state, FormState.QUALITY_CONTROL)
self.assertEqual(result_form.rejected_count, 0)
示例2: test_women_get
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))
示例3: test_dashboard_abort_post
def test_dashboard_abort_post(self):
self._create_and_login_user()
tally = create_tally()
tally.users.add(self.user)
barcode = '123456789'
create_result_form(barcode,
tally=tally,
form_state=FormState.QUALITY_CONTROL)
self._add_user_to_group(self.user, groups.QUALITY_CONTROL_CLERK)
result_form = ResultForm.objects.get(barcode=barcode)
create_quality_control(result_form, self.user)
view = views.QualityControlDashboardView.as_view()
data = {
'result_form': result_form.pk,
'abort': 1,
'tally_id': tally.pk,
}
request = self.factory.post('/', data=data)
request.user = self.user
request.session = {'result_form': result_form.pk}
response = view(request, tally_id=tally.pk)
quality_control = result_form.qualitycontrol_set.all()[0]
self.assertEqual(quality_control.active, False)
self.assertEqual(response.status_code, 302)
self.assertIn('quality-control/home',
response['location'])
self.assertEqual(request.session, {})
示例4: test_quality_control_post
def test_quality_control_post(self):
barcode = '123456789'
self._create_and_login_user()
tally = create_tally()
tally.users.add(self.user)
create_result_form(barcode,
tally=tally,
form_state=FormState.QUALITY_CONTROL)
self._add_user_to_group(self.user, groups.QUALITY_CONTROL_CLERK)
view = views.QualityControlView.as_view()
data = {
'barcode': barcode,
'barcode_copy': barcode,
'tally_id': tally.pk,
}
request = self.factory.post('/', data=data)
request.user = self.user
request.session = {}
response = view(request, tally_id=tally.pk)
self.assertEqual(response.status_code, 302)
self.assertIn('quality-control/dashboard',
response['location'])
result_form = ResultForm.objects.get(barcode=barcode)
self.assertEqual(result_form.form_state, FormState.QUALITY_CONTROL)
self.assertEqual(result_form.qualitycontrol.user, self.user)
示例5: test_dashboard_get
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')
示例6: test_confirm_form_reset_view_post
def test_confirm_form_reset_view_post(self):
self._create_and_login_user()
tally = create_tally()
tally.users.add(self.user)
barcode = '123456789'
ballot = create_ballot(available_for_release=True)
create_result_form(barcode,
tally=tally,
ballot=ballot,
form_state=FormState.QUALITY_CONTROL)
result_form = ResultForm.objects.get(barcode=barcode)
create_quality_control(result_form, self.user)
self._add_user_to_group(self.user, groups.QUALITY_CONTROL_CLERK)
view = views.ConfirmFormResetView.as_view()
reject_reason = 'Form Incorrect'
data = {
'reject_reason': reject_reason
}
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 = ResultForm.objects.get(pk=result_form.pk)
quality_control = result_form.qualitycontrol_set.all()[0]
self.assertEqual(response.status_code, 302)
self.assertIn('quality-control/reject',
response['location'])
self.assertEqual(request.session, {})
self.assertEqual(result_form.form_state, FormState.DATA_ENTRY_1)
self.assertEqual(result_form.rejected_count, 1)
self.assertEqual(result_form.reject_reason, reject_reason)
self.assertFalse(quality_control.active)
self.assertFalse(quality_control.passed_reconciliation)
示例7: test_reconciliation_post_correct
def test_reconciliation_post_correct(self):
self._create_and_login_user()
tally = create_tally()
tally.users.add(self.user)
barcode = '123456789'
create_result_form(barcode,
tally=tally,
form_state=FormState.QUALITY_CONTROL)
result_form = ResultForm.objects.get(barcode=barcode)
create_quality_control(result_form, self.user)
self._add_user_to_group(self.user, groups.QUALITY_CONTROL_CLERK)
view = views.QualityControlDashboardView.as_view()
data = {
'result_form': result_form.pk,
'correct': 1,
'tally_id': tally.pk,
}
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, 302)
self.assertIn('quality-control/print',
response['location'])
quality_control = QualityControl.objects.get(
pk=result_form.qualitycontrol.pk)
self.assertEqual(result_form.form_state, FormState.QUALITY_CONTROL)
self.assertTrue(quality_control.passed_reconciliation)
示例8: 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)
示例9: test_intake_supervisor
def test_intake_supervisor(self):
self._create_and_login_user(username='alice')
self._create_and_login_user()
tally = create_tally()
tally.users.add(self.user)
form_user = self.user
barcode = '123456789'
center = create_center()
create_result_form(barcode,
form_state=FormState.DATA_ENTRY_1,
user=form_user,
tally=tally,
center=center)
self._add_user_to_group(self.user, groups.INTAKE_SUPERVISOR)
view = views.CenterDetailsView.as_view()
barcode_data = {
'barcode': barcode,
'barcode_copy': barcode,
'tally_id': tally.pk,
}
request = self.factory.post('/', data=barcode_data)
request.user = self.user
request.session = {}
response = view(request, tally_id=tally.pk)
self.assertEqual(response.status_code, 302)
self.assertIn('intake/printcover',
response['location'])
result_form = ResultForm.objects.get(barcode=barcode)
self.assertEqual(result_form.form_state, FormState.DATA_ENTRY_1)
self.assertEqual(result_form.user, form_user)
示例10: test_women_get
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))
示例11: test_women_post_incorrect
def test_women_post_incorrect(self):
self._create_and_login_user()
barcode = "123456789"
create_result_form(barcode, form_state=FormState.QUALITY_CONTROL)
result_form = ResultForm.objects.get(barcode=barcode)
create_quality_control(result_form, self.user)
create_candidates(result_form, self.user)
self._add_user_to_group(self.user, groups.QUALITY_CONTROL_CLERK)
view = views.QualityControlDashboardView.as_view()
data = {"result_form": result_form.pk, "incorrect": 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("quality-control/reject", response["location"])
self.assertEqual(result_form.rejected_count, 0)
result_form = ResultForm.objects.get(pk=result_form.pk)
quality_control = result_form.qualitycontrol_set.all()[0]
results = result_form.results.all()
self.assertTrue(len(results) > 0)
for result in results:
self.assertEqual(result.active, False)
self.assertEqual(result_form.form_state, FormState.DATA_ENTRY_1)
self.assertEqual(result_form.rejected_count, 1)
self.assertEqual(quality_control.active, False)
self.assertEqual(quality_control.passed_women, False)
示例12: test_dashboard_submit_post
def test_dashboard_submit_post(self):
barcode = '123456789'
create_result_form(barcode,
form_state=FormState.QUALITY_CONTROL)
self._create_and_login_user()
result_form = ResultForm.objects.get(barcode=barcode)
quality_control = create_quality_control(result_form, self.user)
quality_control.passed_general = True
quality_control.passed_reconciliation = True
quality_control.passed_women = True
quality_control.save()
self._add_user_to_group(self.user, groups.QUALITY_CONTROL_ARCHIVE_CLERK)
view = views.QualityControlDashboardView.as_view()
data = {'result_form': result_form.pk,
'correct': 1}
request = self.factory.post('/', data=data)
request.user = self.user
request.session = {'result_form': result_form.pk}
response = view(request)
result_form = ResultForm.objects.get(pk=result_form.pk)
self.assertEqual(response.status_code, 302)
self.assertIn('quality-control/success',
response['location'])
self.assertEqual(result_form.form_state, FormState.ARCHIVING)
示例13: test_center_detail_redirects_no_center
def test_center_detail_redirects_no_center(self):
self._create_and_login_user()
tally = create_tally()
tally.users.add(self.user)
barcode = '123456789'
create_result_form(barcode,
form_state=FormState.UNSUBMITTED,
tally=tally)
self._add_user_to_group(self.user, groups.INTAKE_CLERK)
view = views.CenterDetailsView.as_view()
barcode_data = {
'barcode': barcode,
'barcode_copy': barcode,
'tally_id': tally.id,
}
request = self.factory.post('/', data=barcode_data)
request.user = self.user
request.session = {}
response = view(request, tally_id=tally.pk)
self.assertEqual(response.status_code, 302)
self.assertIn('intake/enter-center',
response['location'])
result_form = ResultForm.objects.get(barcode=barcode)
self.assertEqual(result_form.form_state, FormState.INTAKE)
self.assertEqual(result_form.user, self.user)
示例14: test_dashboard_get_forms
def test_dashboard_get_forms(self):
create_result_form(form_state=FormState.CLEARANCE,
station_number=42)
response = self._common_view_tests(
views.DashboardView.as_view())
self.assertContains(response, 'Clearance')
self.assertContains(response, '42')
示例15: test_create_clearance_post
def test_create_clearance_post(self):
self._create_and_login_user()
self._add_user_to_group(self.user, groups.CLEARANCE_CLERK)
barcode = 123456789
serial_number = 0
clearable_states = [FormState.CORRECTION,
FormState.DATA_ENTRY_1,
FormState.DATA_ENTRY_2,
FormState.INTAKE,
FormState.QUALITY_CONTROL,
FormState.ARCHIVING,
FormState.UNSUBMITTED]
for form_state in clearable_states:
result_form = create_result_form(form_state=form_state,
barcode=barcode,
serial_number=serial_number)
create_recon_forms(result_form, self.user)
create_candidates(result_form, self.user)
view = views.CreateClearanceView.as_view()
data = {'barcode': result_form.barcode,
'barcode_copy': result_form.barcode}
request = self.factory.post('/', data=data)
request.user = self.user
request.session = data
response = view(request)
result_form.reload()
self.assertEqual(response.status_code, 302)
self.assertEqual(result_form.form_state, FormState.CLEARANCE)
self.assertIsNotNone(result_form.clearance)
self.assertEqual(result_form.clearance.user, self.user)
for result in result_form.reconciliationform_set.all():
self.assertFalse(result.active)
for result in result_form.results.all():
self.assertFalse(result.active)
barcode = barcode + 1
serial_number = serial_number + 1
# unclearable
result_form = create_result_form(form_state=FormState.ARCHIVED,
barcode=barcode,
serial_number=serial_number)
view = views.CreateClearanceView.as_view()
data = {'barcode': result_form.barcode,
'barcode_copy': result_form.barcode}
request = self.factory.post('/', data=data)
request.user = self.user
request.session = data
response = view(request)
result_form.reload()
self.assertEqual(response.status_code, 200)
self.assertEqual(result_form.form_state, FormState.ARCHIVED)