Skip to content
Snippets Groups Projects
Commit f6f913ec authored by Piotr Gawron's avatar Piotr Gawron
Browse files

unit tests for voucher_type view

parent 47f28f7f
No related branches found
No related tags found
1 merge request!112Resolve "voucher types"
......@@ -5,7 +5,8 @@ import os
from django.contrib.auth.models import User
from web.models import Location, AppointmentType, StudySubject, Worker, Visit, Appointment, ConfigurationItem, \
Language, ContactAttempt, FlyingTeam, Availability, Subject, Study, StudyColumns, StudyNotificationParameters
Language, ContactAttempt, FlyingTeam, Availability, Subject, Study, StudyColumns, StudyNotificationParameters, \
VoucherType
from web.models.constants import REDCAP_TOKEN_CONFIGURATION_TYPE, REDCAP_BASE_URL_CONFIGURATION_TYPE, \
SEX_CHOICES_MALE, SUBJECT_TYPE_CHOICES_CONTROL, CONTACT_TYPES_PHONE, \
MONDAY_AS_DAY_OF_WEEK, COUNTRY_AFGHANISTAN_ID
......@@ -26,6 +27,10 @@ def create_location(name="test"):
return Location.objects.create(name=name)
def create_voucher_type():
return VoucherType.objects.create(code="X", study=get_test_study())
def create_empty_study_columns():
study_columns = StudyColumns.objects.create(
postponed=False,
......
import logging
from django.urls import reverse
from web.models import VoucherType
from web.models.constants import GLOBAL_STUDY_ID
from web.tests.functions import create_voucher_type
from .. import LoggedInTestCase
logger = logging.getLogger(__name__)
class VoucherTypeViewTests(LoggedInTestCase):
def test_render_add_voucher_type_request(self):
response = self.client.get(reverse('web.views.voucher_type_add'))
self.assertEqual(response.status_code, 200)
def test_render_edit_voucher_type_request(self):
voucher_type = create_voucher_type()
response = self.client.get(reverse('web.views.voucher_type_edit', kwargs={'pk': voucher_type.id}))
self.assertEqual(response.status_code, 200)
def test_add_voucher_type(self):
form_data = {
'code': "X",
'description': "y",
'study': str(GLOBAL_STUDY_ID),
}
response = self.client.post(reverse('web.views.voucher_type_add'), data=form_data)
self.assertEqual(response.status_code, 302)
self.assertEqual(1, VoucherType.objects.all().count())
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment