本文整理汇总了Python中tally_ho.libs.tests.test_base.create_tally函数的典型用法代码示例。如果您正苦于以下问题:Python create_tally函数的具体用法?Python create_tally怎么用?Python create_tally使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了create_tally函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_review_post_forward
def test_review_post_forward(self):
self._create_and_login_user()
self._add_user_to_group(self.user, groups.CLEARANCE_CLERK)
tally = create_tally()
tally.users.add(self.user)
result_form = create_result_form(form_state=FormState.CLEARANCE,
tally=tally)
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)
clearance = result_form.clearance
self.assertEqual(clearance.user, self.user)
self.assertEqual(clearance.reviewed_team, True)
self.assertEqual(clearance.action_prior_to_recommendation,
ActionsPrior.REQUEST_AUDIT_ACTION_FROM_FIELD)
self.assertEqual(response.status_code, 302)
开发者ID:onaio,项目名称:tally-ho,代码行数:28,代码来源:test_clearance.py
示例2: 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)
开发者ID:onaio,项目名称:tally-ho,代码行数:30,代码来源:test_intake.py
示例3: test_print_quarantine_get
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')
开发者ID:onaio,项目名称:tally-ho,代码行数:29,代码来源:test_quality_control.py
示例4: 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)
开发者ID:onaio,项目名称:tally-ho,代码行数:32,代码来源:test_quality_control.py
示例5: 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, {})
开发者ID:onaio,项目名称:tally-ho,代码行数:28,代码来源:test_quality_control.py
示例6: 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)
开发者ID:onaio,项目名称:tally-ho,代码行数:25,代码来源:test_quality_control.py
示例7: 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))
开发者ID:onaio,项目名称:tally-ho,代码行数:31,代码来源:test_quality_control.py
示例8: 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)
开发者ID:onaio,项目名称:tally-ho,代码行数:34,代码来源:test_quality_control.py
示例9: test_general_post_correct
def test_general_post_correct(self):
self._create_and_login_user()
tally = create_tally()
tally.users.add(self.user)
barcode = '123456789'
result_form = create_result_form(barcode,
tally=tally,
form_state=FormState.QUALITY_CONTROL)
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.id,
}
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_general)
开发者ID:onaio,项目名称:tally-ho,代码行数:29,代码来源:test_quality_control.py
示例10: test_dashboard_get
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')
开发者ID:onaio,项目名称:tally-ho,代码行数:28,代码来源:test_quality_control.py
示例11: 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)
开发者ID:onaio,项目名称:tally-ho,代码行数:26,代码来源:test_quality_control.py
示例12: 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'])
开发者ID:onaio,项目名称:tally-ho,代码行数:26,代码来源:test_data_entry.py
示例13: test_review_post_supervisor_implement
def test_review_post_supervisor_implement(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_number = 2
result_form = create_result_form(form_state=FormState.CLEARANCE,
center=center,
tally=tally,
station_number=station_number)
self.assertEqual(result_form.center, center)
self.assertEqual(result_form.station_number, station_number)
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='alice')
self._add_user_to_group(self.user, groups.CLEARANCE_SUPERVISOR)
tally.users.add(self.user)
view = views.ReviewView.as_view()
data = {
'result_form': result_form.pk,
'action_prior_to_recommendation': 1,
'resolution_recommendation': 3,
'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)
clearance = result_form.clearances.all()[0]
result_form.reload()
self.assertEqual(clearance.supervisor, self.user)
self.assertFalse(clearance.active)
self.assertTrue(clearance.reviewed_supervisor)
self.assertTrue(clearance.reviewed_team)
self.assertEqual(clearance.action_prior_to_recommendation,
ActionsPrior.REQUEST_AUDIT_ACTION_FROM_FIELD)
self.assertEqual(response.status_code, 302)
self.assertEqual(result_form.form_state, FormState.UNSUBMITTED)
self.assertEqual(result_form.center, center)
self.assertEqual(result_form.station_number, station_number)
开发者ID:onaio,项目名称:tally-ho,代码行数:60,代码来源:test_clearance.py
示例14: 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'])
开发者ID:onaio,项目名称:tally-ho,代码行数:35,代码来源:test_quality_control.py
示例15: 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')
开发者ID:onaio,项目名称:tally-ho,代码行数:25,代码来源:test_data_entry.py
示例16: test_intake_clerk_selects_matches
def test_intake_clerk_selects_matches(self):
self._create_and_login_user()
tally = create_tally()
tally.users.add(self.user)
barcode = '123456789'
center = create_center(tally=tally)
result_form = create_result_form(barcode,
center=center,
tally=tally)
self._add_user_to_group(self.user, groups.INTAKE_CLERK)
view = views.CheckCenterDetailsView.as_view()
post_data = {
'result_form': result_form.pk,
'is_match': 'true',
'tally_id': tally.id,
}
request = self.factory.post('/', data=post_data)
request.user = self.user
request.session = {'result_form': result_form.pk}
with self.assertRaises(Exception):
response = view(request)
result_form.form_state = FormState.INTAKE
result_form.save()
response = view(request, tally_id=tally.pk)
self.assertEqual(response.status_code, 302)
self.assertIn('/intake/printcover', response['location'])
开发者ID:onaio,项目名称:tally-ho,代码行数:26,代码来源:test_intake.py
示例17: 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)
开发者ID:onaio,项目名称:tally-ho,代码行数:33,代码来源:test_clearance.py
示例18: 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)
开发者ID:onaio,项目名称:tally-ho,代码行数:25,代码来源:test_intake.py
示例19: 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)
开发者ID:onaio,项目名称:tally-ho,代码行数:30,代码来源:test_intake.py
示例20: test_center_detail_invalid_center
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')
开发者ID:onaio,项目名称:tally-ho,代码行数:30,代码来源:test_data_entry.py
注:本文中的tally_ho.libs.tests.test_base.create_tally函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论