diff --git a/smash/web/migrations/0066_subject.py b/smash/web/migrations/0066_subject.py new file mode 100644 index 0000000000000000000000000000000000000000..511f3560a02a48efb4d3a708ed1e538deab50795 --- /dev/null +++ b/smash/web/migrations/0066_subject.py @@ -0,0 +1,32 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.10.7 on 2017-11-27 10:42 +from __future__ import unicode_literals + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('web', '0065_auto_20171127_0957'), + ] + + operations = [ + migrations.RunSQL('alter sequence web_subject_id_seq rename to web_studysubject_id_seq;'), + migrations.RunSQL('alter sequence web_subject_languages_id_seq rename to web_studysubject_languages_id_seq;'), + migrations.RunSQL('alter table web_studysubject rename constraint web_subject_flying_team_id_ef78de5d_fk_web_flyingteam_id to web_studysubject_flying_team_id_ef78de5d_fk_web_flyingteam_id;'), + migrations.RunSQL('alter table web_studysubject_languages rename constraint web_subject_languages_language_id_80eca4c1_fk_web_language_id to web_studysubject_languages_language_id_80eca4c1_fk_web_language_id;'), + migrations.RunSQL('alter table web_studysubject rename constraint web_subject_country_id_5d976875_fk_web_country_id to web_studysubject_country_id_5d976875_fk_web_country_id;'), + migrations.RunSQL('alter table web_studysubject rename constraint web_subject_default_location_id_da83b714_fk_web_location_id to web_studyubject_default_location_id_da83b714_fk_web_location_id;'), + migrations.RunSQL('alter table web_studysubject rename constraint web_subject_pkey to web_studysubject_pkey;'), + migrations.RunSQL('alter table web_studysubject_languages rename constraint web_subject_languages_pkey to web_studysubject_languages_pkey;'), + migrations.RunSQL('alter table web_studysubject_languages rename constraint web_subject_languages_subject_id_a5eb4f49_uniq to web_studysubject_languages_subject_id_a5eb4f49_uniq;'), + migrations.RunSQL('alter index if exists web_subject_15d1b6cd rename to web_studysubject_15d1b6cd;'), + migrations.RunSQL('alter index if exists web_subject_496f9482 rename to web_studysubject_496f9482;'), + migrations.RunSQL('alter index if exists web_subject_84b500ff rename to web_studysubject_84b500ff;'), + migrations.RunSQL('alter index if exists web_subject_9571fdf9 rename to web_studysubject_9571fdf9;'), + migrations.RunSQL('alter index if exists web_subject_languages_468679bd rename to web_studysubject_languages_468679bd;'), + migrations.RunSQL('alter index if exists web_subject_languages_ffaba1d1 rename to web_studysubject_languages_ffaba1d1;'), + migrations.RunSQL('alter index if exists web_subject_screening_number_75aa70c7_like rename to web_studysubject_screening_number_75aa70c7_like;') + ] diff --git a/smash/web/migrations/0067_subject.py b/smash/web/migrations/0067_subject.py new file mode 100644 index 0000000000000000000000000000000000000000..6039e17520676f685812939e069109492ba20cf5 --- /dev/null +++ b/smash/web/migrations/0067_subject.py @@ -0,0 +1,68 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.10.7 on 2017-11-27 13:29 +from __future__ import unicode_literals + +import django.db.models.deletion +from django.db import migrations, models + + +class Migration(migrations.Migration): + dependencies = [ + ('web', '0066_subject'), + ] + + operations = [ + migrations.CreateModel( + name='Subject', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('tmp_study_subject_id', models.IntegerField()), + ('sex', + models.CharField(choices=[(b'M', b'Male'), (b'F', b'Female')], max_length=1, verbose_name=b'Sex')), + ('first_name', models.CharField(max_length=50, verbose_name=b'First name')), + ('last_name', models.CharField(max_length=50, verbose_name=b'Last name')), + ('phone_number', models.CharField(blank=True, max_length=20, null=True, verbose_name=b'Phone number')), + ('phone_number_2', + models.CharField(blank=True, max_length=20, null=True, verbose_name=b'Phone number 2')), + ('phone_number_3', + models.CharField(blank=True, max_length=20, null=True, verbose_name=b'Phone number 3')), + ('email', models.EmailField(blank=True, max_length=254, null=True, verbose_name=b'E-mail')), + ('date_born', models.DateField(blank=True, null=True, verbose_name=b'Date of birth (YYYY-MM-DD)')), + ('address', models.CharField(blank=True, max_length=255, verbose_name=b'Address')), + ('postal_code', models.CharField(blank=True, max_length=7, verbose_name=b'Postal code')), + ('city', models.CharField(blank=True, max_length=50, verbose_name=b'City')), + ('dead', models.BooleanField(default=False, verbose_name=b'Deceased')), + ('country', models.ForeignKey(default=1, on_delete=django.db.models.deletion.CASCADE, to='web.Country', + verbose_name=b'Country')), + ('default_written_communication_language', + models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, + related_name='subjects_written_communication', to='web.Language', + verbose_name=b'Default language for document generation')), + ('languages', models.ManyToManyField(blank=True, to='web.Language', verbose_name=b'Known languages')), + ], + ), + migrations.RunSQL('insert into web_subject (tmp_study_subject_id, sex, first_name, last_name, phone_number, ' + + 'phone_number_2, phone_number_3, email, date_born, address, postal_code, city, dead, ' + + 'country_id, default_written_communication_language_id) ' + + 'select id, sex, first_name, last_name, phone_number, phone_number_2, phone_number_3, ' + + 'email, date_born, address, postal_code, city, dead, country_id, ' + 'default_written_communication_language_id from web_studysubject;'), + migrations.AddField( + model_name='studysubject', + name='subject', + field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to='web.Subject', + verbose_name=b'Subject'), + ), + migrations.RunSQL('update web_studysubject set subject_id = ' + + '(select id from web_subject where tmp_study_subject_id =web_studysubject.id);'), + migrations.RemoveField( + model_name='subject', + name='tmp_study_subject_id', + ), + migrations.AlterField( + model_name='studysubject', + name='subject', + field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='web.Subject', + verbose_name=b'Subject'), + ), + ] diff --git a/smash/web/models/__init__.py b/smash/web/models/__init__.py index 5cb87ceccdbf70492b1f66b18b9b2eeba83282d6..2b7f7dba19788a6778d0430ed60436cc0c6c4e88 100644 --- a/smash/web/models/__init__.py +++ b/smash/web/models/__init__.py @@ -17,6 +17,7 @@ from availability import Availability from holiday import Holiday from item import Item from language import Language +from subject import Subject from study_subject import StudySubject from contact_attempt import ContactAttempt from mail_template import MailTemplate @@ -24,6 +25,6 @@ from missing_subject import MissingSubject from inconsistent_subject import InconsistentSubject, InconsistentField -__all__ = [FlyingTeam, Appointment, AppointmentType, Availability, Holiday, Item, Language, Location, Room, StudySubject, +__all__ = [FlyingTeam, Appointment, AppointmentType, Availability, Holiday, Item, Language, Location, Room, Subject, StudySubject, Visit, Worker, ContactAttempt, ConfigurationItem, MailTemplate, AppointmentTypeLink, MissingSubject, InconsistentSubject, InconsistentField, Country] diff --git a/smash/web/models/study_subject.py b/smash/web/models/study_subject.py index fa3e65a9c7d3c5352ae4b22e97ab051428976288..2c52d3321aa374160d946ec19673a1b1bfe8c782 100644 --- a/smash/web/models/study_subject.py +++ b/smash/web/models/study_subject.py @@ -33,6 +33,11 @@ class StudySubject(models.Model): self.finish_all_visits() self.finish_all_appointments() + subject = models.ForeignKey("web.Subject", + verbose_name='Subject', + null=False, + ) + sex = models.CharField(max_length=1, choices=SEX_CHOICES, verbose_name='Sex' @@ -127,7 +132,8 @@ class StudySubject(models.Model): blank=True, verbose_name='ND number', validators=[ - RegexValidator('^(ND[0-9]{4}|)$', message="ND number should look as follows: NDxxxx")] + RegexValidator('^(ND[0-9]{4}|)$', + message="ND number should look as follows: NDxxxx")] ) mpower_id = models.CharField(max_length=20, blank=True, diff --git a/smash/web/models/subject.py b/smash/web/models/subject.py new file mode 100644 index 0000000000000000000000000000000000000000..ee7836ec794e80e626fa9d322b84e1db82515cd0 --- /dev/null +++ b/smash/web/models/subject.py @@ -0,0 +1,99 @@ +# coding=utf-8 +from django.db import models + +from constants import SEX_CHOICES, COUNTRY_OTHER_ID +from web.models import Country +from . import Language + + +class Subject(models.Model): + class Meta: + app_label = 'web' + + sex = models.CharField(max_length=1, + choices=SEX_CHOICES, + verbose_name='Sex' + ) + + first_name = models.CharField(max_length=50, + verbose_name='First name' + ) + + last_name = models.CharField(max_length=50, + verbose_name='Last name' + ) + + languages = models.ManyToManyField(Language, + blank=True, + verbose_name='Known languages' + ) + + default_written_communication_language = models.ForeignKey(Language, + null=True, + blank=True, + related_name="subjects_written_communication", + verbose_name='Default language for document generation' + ) + phone_number = models.CharField(max_length=20, + null=True, + blank=True, + verbose_name='Phone number' + ) + + phone_number_2 = models.CharField(max_length=20, + null=True, + blank=True, + verbose_name='Phone number 2' + ) + + phone_number_3 = models.CharField(max_length=20, + null=True, + blank=True, + verbose_name='Phone number 3' + ) + + email = models.EmailField( + null=True, + blank=True, + verbose_name='E-mail' + ) + + date_born = models.DateField( + null=True, + blank=True, + verbose_name='Date of birth (YYYY-MM-DD)' + ) + + address = models.CharField(max_length=255, + blank=True, + verbose_name='Address' + ) + + postal_code = models.CharField(max_length=7, + blank=True, + verbose_name='Postal code' + ) + + city = models.CharField(max_length=50, + blank=True, + verbose_name='City' + ) + + country = models.ForeignKey(Country, + null=False, + blank=False, + default=COUNTRY_OTHER_ID, + verbose_name='Country' + ) + + dead = models.BooleanField( + verbose_name='Deceased', + default=False, + editable=True + ) + + def __str__(self): + return "%s %s" % (self.first_name, self.last_name) + + def __unicode__(self): + return "%s %s" % (self.first_name, self.last_name) diff --git a/smash/web/tests/api_views/test_appointment.py b/smash/web/tests/api_views/test_appointment.py index b6e11b47ab024922ac51394591356279f0166517..a5becb87117ee9b0cead3d291757117e6be29a30 100644 --- a/smash/web/tests/api_views/test_appointment.py +++ b/smash/web/tests/api_views/test_appointment.py @@ -8,7 +8,7 @@ from django.test import TestCase from django.urls import reverse from web.models import AppointmentTypeLink -from web.tests.functions import create_subject, create_worker, create_visit, create_appointment, \ +from web.tests.functions import create_study_subject, create_worker, create_visit, create_appointment, \ create_appointment_type, create_get_suffix from web.views.appointment import APPOINTMENT_LIST_GENERIC, APPOINTMENT_LIST_APPROACHING, APPOINTMENT_LIST_UNFINISHED from web.views.notifications import get_today_midnight_date @@ -16,7 +16,7 @@ from web.views.notifications import get_today_midnight_date class TestApi(TestCase): def setUp(self): - self.subject = create_subject() + self.subject = create_study_subject() self.client = Client() username = 'piotr' password = 'top_secret' diff --git a/smash/web/tests/api_views/test_daily_planning.py b/smash/web/tests/api_views/test_daily_planning.py index 257e4d7abdd681e9a03c028189879b05160b4622..abaea166149c9dbf02967115040209f5fcaa9cb8 100644 --- a/smash/web/tests/api_views/test_daily_planning.py +++ b/smash/web/tests/api_views/test_daily_planning.py @@ -10,7 +10,7 @@ from django.urls import reverse from web.api_views.daily_planning import get_workers_for_daily_planning, get_generic_appointment_events from web.models import Worker, Availability, Holiday, AppointmentTypeLink from web.models.constants import TUESDAY_AS_DAY_OF_WEEK -from web.tests.functions import create_worker, create_subject, create_appointment, create_flying_team, create_visit, \ +from web.tests.functions import create_worker, create_study_subject, create_appointment, create_flying_team, create_visit, \ create_appointment_type, get_test_location @@ -38,7 +38,7 @@ class TestApi(TestCase): flying_team = create_flying_team() flying_team.place = "UTF name: ät" flying_team.save() - subject = create_subject() + subject = create_study_subject() visit = create_visit(subject) appointment = create_appointment(visit) diff --git a/smash/web/tests/api_views/test_subject.py b/smash/web/tests/api_views/test_subject.py index 7ad048d35389de7244db494daeccb39681895304..576cd3540781f8313fab6fb6b91737edf4b95743 100644 --- a/smash/web/tests/api_views/test_subject.py +++ b/smash/web/tests/api_views/test_subject.py @@ -11,12 +11,12 @@ from web.views.notifications import get_today_midnight_date from web.api_views.subject import get_subjects_order, get_subjects_filtered, serialize_subject, SUBJECT_LIST_GENERIC, \ SUBJECT_LIST_NO_VISIT, SUBJECT_LIST_REQUIRE_CONTACT from web.models import StudySubject, Appointment, Visit -from web.tests.functions import create_subject, create_worker, create_get_suffix, create_visit, create_appointment +from web.tests.functions import create_study_subject, create_worker, create_get_suffix, create_visit, create_appointment class TestApi(TestCase): def setUp(self): - self.subject = create_subject() + self.subject = create_study_subject() self.client = Client() username = 'piotr' password = 'top_secret' @@ -120,7 +120,7 @@ class TestApi(TestCase): subject.nd_number = "PPP" subject.save() - subject2 = create_subject(2) + subject2 = create_study_subject(2) subject2.nd_number = "QQQ" subject2.save() @@ -129,7 +129,7 @@ class TestApi(TestCase): def test_subjects_sort_id(self): subject = self.subject - subject2 = create_subject(2) + subject2 = create_study_subject(2) self.check_subject_ordered("id", [subject, subject2]) @@ -138,7 +138,7 @@ class TestApi(TestCase): subject.date_born = get_today_midnight_date() subject.save() - subject2 = create_subject(2) + subject2 = create_study_subject(2) subject2.date_born = get_today_midnight_date() + datetime.timedelta(days=1) subject2.save() @@ -154,7 +154,7 @@ class TestApi(TestCase): subject.screening_number = "PPP" subject.save() - subject2 = create_subject(2) + subject2 = create_study_subject(2) subject2.screening_number = "QQQ" subject2.save() @@ -165,7 +165,7 @@ class TestApi(TestCase): subject.last_name = "XXX" subject.save() - subject2 = create_subject(2) + subject2 = create_study_subject(2) subject2.last_name = "YYY" subject2.save() @@ -176,7 +176,7 @@ class TestApi(TestCase): subject.dead = True subject.save() - subject2 = create_subject(2) + subject2 = create_study_subject(2) subject2.dead = False subject2.save() @@ -187,7 +187,7 @@ class TestApi(TestCase): subject.resigned = True subject.save() - subject2 = create_subject(2) + subject2 = create_study_subject(2) subject2.resigned = False subject2.save() @@ -198,7 +198,7 @@ class TestApi(TestCase): subject.postponed = True subject.save() - subject2 = create_subject(2) + subject2 = create_study_subject(2) subject2.postponed = False subject2.save() @@ -209,7 +209,7 @@ class TestApi(TestCase): subject.dead = True subject.save() - subject2 = create_subject(2) + subject2 = create_study_subject(2) subject2.dead = False subject2.save() @@ -221,7 +221,7 @@ class TestApi(TestCase): subject.nd_number = "PPP" subject.save() - subject2 = create_subject(2) + subject2 = create_study_subject(2) subject2.nd_number = "QQQ" subject2.save() @@ -232,7 +232,7 @@ class TestApi(TestCase): subject.screening_number = "PPP" subject.save() - subject2 = create_subject(2) + subject2 = create_study_subject(2) subject2.screening_number = "QQQ" subject2.save() @@ -243,7 +243,7 @@ class TestApi(TestCase): subject.last_name = "XXX" subject.save() - subject2 = create_subject(2) + subject2 = create_study_subject(2) subject2.last_name = "YYY" subject2.save() @@ -254,7 +254,7 @@ class TestApi(TestCase): subject.resigned = True subject.save() - subject2 = create_subject(2) + subject2 = create_study_subject(2) subject2.resigned = False subject2.save() @@ -266,7 +266,7 @@ class TestApi(TestCase): subject.postponed = True subject.save() - subject2 = create_subject(2) + subject2 = create_study_subject(2) subject2.postponed = False subject2.save() diff --git a/smash/web/tests/forms/test_SubjectAddForm.py b/smash/web/tests/forms/test_SubjectAddForm.py index 907cfe39d93200d6bfedff92d7f18a4463d085fa..1c743a8bdf51cc315c92a245021038722fca7be3 100644 --- a/smash/web/tests/forms/test_SubjectAddForm.py +++ b/smash/web/tests/forms/test_SubjectAddForm.py @@ -1,7 +1,7 @@ from web.forms import SubjectAddForm, get_new_screening_number from web.models.constants import SEX_CHOICES_MALE, SUBJECT_TYPE_CHOICES_CONTROL, COUNTRY_AFGHANISTAN_ID from web.tests import LoggedInWithWorkerTestCase -from web.tests.functions import create_subject +from web.tests.functions import create_study_subject class SubjectAddFormTests(LoggedInWithWorkerTestCase): @@ -70,7 +70,7 @@ class SubjectAddFormTests(LoggedInWithWorkerTestCase): def test_get_new_screening_number(self): prefix = "X-" - subject = create_subject() + subject = create_study_subject() subject.screening_number = prefix + "300" subject.save() @@ -79,7 +79,7 @@ class SubjectAddFormTests(LoggedInWithWorkerTestCase): def test_get_new_screening_number_2(self): prefix = "X-" - subject = create_subject() + subject = create_study_subject() subject.screening_number = "L-1111; " + prefix + "300" subject.save() @@ -88,7 +88,7 @@ class SubjectAddFormTests(LoggedInWithWorkerTestCase): def test_get_new_screening_number_3(self): prefix = "X-" - subject = create_subject() + subject = create_study_subject() subject.screening_number = "P-1112; " + prefix + "300" + "; L-1111" subject.save() @@ -97,7 +97,7 @@ class SubjectAddFormTests(LoggedInWithWorkerTestCase): def test_get_new_screening_number_4(self): prefix = "X-" - subject = create_subject() + subject = create_study_subject() subject.screening_number = "P-1112; " subject.save() @@ -106,19 +106,19 @@ class SubjectAddFormTests(LoggedInWithWorkerTestCase): def test_get_new_screening_number_5(self): prefix = "X-" - subject = create_subject() + subject = create_study_subject() subject.screening_number = prefix + "100" subject.save() - subject = create_subject() + subject = create_study_subject() subject.screening_number = prefix + "200" subject.save() - subject = create_subject() + subject = create_study_subject() subject.screening_number = "Y-300" subject.save() - subject = create_subject() + subject = create_study_subject() subject.screening_number = prefix + "20" subject.save() @@ -127,7 +127,7 @@ class SubjectAddFormTests(LoggedInWithWorkerTestCase): def test_get_new_screening_number_6(self): prefix = "X-" - subject = create_subject() + subject = create_study_subject() subject.screening_number = "X-" subject.save() diff --git a/smash/web/tests/forms/test_VisitAddForm.py b/smash/web/tests/forms/test_VisitAddForm.py index b6a0d817ad2b577e83bcbf9a03fbfd71b3baf6f7..14fbed837708331b331bdaf415d859ce9a13ca7b 100644 --- a/smash/web/tests/forms/test_VisitAddForm.py +++ b/smash/web/tests/forms/test_VisitAddForm.py @@ -3,14 +3,14 @@ from __future__ import print_function from django.test import TestCase from web.forms import VisitAddForm -from web.tests.functions import create_subject +from web.tests.functions import create_study_subject from web.tests.functions import get_test_location class VisitAddFormTests(TestCase): def setUp(self): get_test_location() - self.subject = create_subject() + self.subject = create_study_subject() self.sample_data = {'datetime_begin': "2017-01-01", 'datetime_end': "2017-02-02", diff --git a/smash/web/tests/functions.py b/smash/web/tests/functions.py index eb904f6e5bca62b9320d1fd80193f0cb022df803..66d1c1cc9464bcea6966b006d2f21819b7d2eabd 100644 --- a/smash/web/tests/functions.py +++ b/smash/web/tests/functions.py @@ -4,7 +4,7 @@ import os from django.contrib.auth.models import User from web.models import Location, AppointmentType, StudySubject, Worker, Visit, Appointment, ConfigurationItem, Language, \ - ContactAttempt, FlyingTeam, Availability + ContactAttempt, FlyingTeam, Availability, Subject 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 @@ -41,7 +41,7 @@ def create_appointment_type(): def create_contact_attempt(subject=None, worker=None): if subject is None: - subject = create_subject() + subject = create_study_subject() if worker is None: worker = create_worker() @@ -54,7 +54,18 @@ def create_contact_attempt(subject=None, worker=None): ) -def create_subject(subject_id=1): +def create_subject(): + return Subject.objects.create( + first_name="Piotr", + last_name="Gawron", + sex=SEX_CHOICES_MALE, + country_id=COUNTRY_AFGHANISTAN_ID + ) + + +def create_study_subject(subject_id=1, subject=None): + if subject is None: + subject = create_subject() return StudySubject.objects.create( first_name="Piotr", last_name="Gawron", @@ -62,7 +73,9 @@ def create_subject(subject_id=1): sex=SEX_CHOICES_MALE, type=SUBJECT_TYPE_CHOICES_CONTROL, screening_number="piotr's number" + str(subject_id), - country_id=COUNTRY_AFGHANISTAN_ID + country_id=COUNTRY_AFGHANISTAN_ID, + subject=subject + ) @@ -112,7 +125,7 @@ def create_availability(worker=None): def create_visit(subject=None): if subject is None: - subject = create_subject() + subject = create_study_subject() return Visit.objects.create(datetime_begin=get_today_midnight_date() + datetime.timedelta(days=-31), datetime_end=get_today_midnight_date() + datetime.timedelta(days=31), subject=subject, diff --git a/smash/web/tests/models/test_inconsistent_subject.py b/smash/web/tests/models/test_inconsistent_subject.py index 926314158302ac7bb18ed4900a7c2ba1fa0d5216..1ee33c4e38a2e1ef0706fd3f5b2864758413251d 100644 --- a/smash/web/tests/models/test_inconsistent_subject.py +++ b/smash/web/tests/models/test_inconsistent_subject.py @@ -1,12 +1,12 @@ from django.test import TestCase from web.models.inconsistent_subject import InconsistentSubject, InconsistentField -from web.tests.functions import create_subject +from web.tests.functions import create_study_subject class InconsistentSubjectTests(TestCase): def test_create_with_empty_data(self): - subject = create_subject() + subject = create_study_subject() inconsistent_subject = InconsistentSubject.create(subject) self.assertIsNotNone(str(inconsistent_subject)) self.assertIsNotNone(unicode(inconsistent_subject)) diff --git a/smash/web/tests/models/test_mail_template.py b/smash/web/tests/models/test_mail_template.py index d718ba2e5ddf4a02f283ae4008d6297b831ec5b5..53f8b2f196c064897b284c3dc20931e481956944 100644 --- a/smash/web/tests/models/test_mail_template.py +++ b/smash/web/tests/models/test_mail_template.py @@ -7,7 +7,7 @@ from web.models import MailTemplate from web.models.constants import MAIL_TEMPLATE_CONTEXT_APPOINTMENT, MAIL_TEMPLATE_CONTEXT_VISIT, \ MAIL_TEMPLATE_CONTEXT_SUBJECT from web.models.mail_template import DATE_FORMAT_SHORT -from web.tests.functions import create_language, get_resource_path, create_appointment, create_user, create_subject, \ +from web.tests.functions import create_language, get_resource_path, create_appointment, create_user, create_study_subject, \ create_visit @@ -80,7 +80,7 @@ class MailTemplateModelTests(TestCase): def test_apply_subject(self): template_name_french = "test_fr" - subject = create_subject() + subject = create_study_subject() subject_template_french = MailTemplate(name=template_name_french, language=self.french_language, context=MAIL_TEMPLATE_CONTEXT_SUBJECT, template_file=self.template_file) diff --git a/smash/web/tests/models/test_missing_subject.py b/smash/web/tests/models/test_missing_subject.py index 37a7f92459ec0ad09ae3ec06203f370712eb95d7..712969a9b125ca8b4e7a6c80ed735aac3f601fa0 100644 --- a/smash/web/tests/models/test_missing_subject.py +++ b/smash/web/tests/models/test_missing_subject.py @@ -1,12 +1,12 @@ from django.test import TestCase from web.models.missing_subject import MissingSubject -from web.tests.functions import create_subject, create_red_cap_subject +from web.tests.functions import create_study_subject, create_red_cap_subject class MissingSubjectTests(TestCase): def test_create_with_empty_redcap_subject(self): - subject = create_subject() + subject = create_study_subject() missing_subject = MissingSubject.create(red_cap_subject=None, smash_subject=subject) self.assertIsNotNone(str(missing_subject)) self.assertIsNotNone(unicode(missing_subject)) diff --git a/smash/web/tests/models/test_subject.py b/smash/web/tests/models/test_subject.py index 3e3f5e0165564c6b9f0edf80388a5a6bd1399df7..1b60733e30d2f01f3c15dcb22cfedeacbd078173 100644 --- a/smash/web/tests/models/test_subject.py +++ b/smash/web/tests/models/test_subject.py @@ -2,15 +2,15 @@ from django.contrib.auth.models import User from django.test import Client from django.test import TestCase -from web.tests.functions import create_subject, create_appointment, create_worker +from web.tests.functions import create_study_subject, create_appointment, create_worker from web.tests.functions import create_visit from web.models import Appointment from web.models import Visit -class SubjectMtodelTests(TestCase): +class SubjectModelTests(TestCase): def test_mark_as_dead(self): - subject = create_subject() + subject = create_study_subject() visit = create_visit(subject) appointment = create_appointment(visit) @@ -23,7 +23,7 @@ class SubjectMtodelTests(TestCase): self.assertEquals(Appointment.APPOINTMENT_STATUS_CANCELLED, appointment_status) def test_mark_as_resigned(self): - subject = create_subject() + subject = create_study_subject() visit = create_visit(subject) appointment = create_appointment(visit) diff --git a/smash/web/tests/models/test_visit.py b/smash/web/tests/models/test_visit.py index f4a231344474b3eb0b946ea9cb0e8b5dbc6f65a2..6d5e7d8e541fe37214f61f48fdcd0346a7763bc0 100644 --- a/smash/web/tests/models/test_visit.py +++ b/smash/web/tests/models/test_visit.py @@ -4,13 +4,13 @@ from django.test import TestCase from web.models.constants import SUBJECT_TYPE_CHOICES_PATIENT from web.models import Visit -from web.tests.functions import create_subject, create_visit +from web.tests.functions import create_study_subject, create_visit from web.views.notifications import get_today_midnight_date class VisitModelTests(TestCase): def test_mark_as_finished(self): - subject = create_subject() + subject = create_study_subject() visit = create_visit(subject) visit.mark_as_finished() @@ -19,7 +19,7 @@ class VisitModelTests(TestCase): self.assertEquals(2, visit_count) def test_mark_as_finished_2(self): - subject = create_subject() + subject = create_study_subject() visit = create_visit(subject) subject.dead = True subject.save() @@ -30,7 +30,7 @@ class VisitModelTests(TestCase): self.assertEquals(1, visit_count) def test_mark_as_finished_3(self): - subject = create_subject() + subject = create_study_subject() visit = create_visit(subject) subject.resigned = True subject.save() @@ -41,7 +41,7 @@ class VisitModelTests(TestCase): self.assertEquals(1, visit_count) def test_mark_as_finished_for_follow_up_visit(self): - subject = create_subject() + subject = create_study_subject() subject.type = SUBJECT_TYPE_CHOICES_PATIENT subject.save() visit = create_visit(subject) @@ -64,9 +64,9 @@ class VisitModelTests(TestCase): self.assertTrue(visit.datetime_begin + datetime.timedelta(days=365 * 2 - 1) < new_follow_up.datetime_begin) def test_visit_to_string(self): - visit = create_visit(create_subject()) + visit = create_visit(create_study_subject()) self.assertIsNotNone(str(visit)) def test_visit_to_unicode(self): - visit = create_visit(create_subject()) + visit = create_visit(create_study_subject()) self.assertIsNotNone(unicode(visit)) diff --git a/smash/web/tests/test_RedcapConnector.py b/smash/web/tests/test_RedcapConnector.py index de3a1378a67218bfd393cfc4cd8efffd5f03ed02..3fc4c9d7cc4dc5b8bbf998e4b2becbc68e5fef94 100644 --- a/smash/web/tests/test_RedcapConnector.py +++ b/smash/web/tests/test_RedcapConnector.py @@ -4,7 +4,7 @@ import logging from django.test import TestCase -from functions import create_subject, prepare_test_redcap_connection +from functions import create_study_subject, prepare_test_redcap_connection from web.models import Language from web.models.inconsistent_subject import InconsistentSubject from web.models.missing_subject import MissingSubject @@ -39,7 +39,7 @@ class TestRedcapConnector(TestCase): def test_get_invalid_connections_for_new_local(self): prepare_test_redcap_connection() - subject = create_subject() + subject = create_study_subject() subject.nd_number = "123" subject.save() @@ -49,7 +49,7 @@ class TestRedcapConnector(TestCase): def test_get_inconsistent_data(self): prepare_test_redcap_connection() - subject = create_subject() + subject = create_study_subject() # noinspection SpellCheckingInspection subject.nd_number = 'NDtest_external' subject.save() @@ -72,7 +72,7 @@ class TestRedcapConnector(TestCase): def test_create_inconsistent_data_for_date_born(self): prepare_test_redcap_connection() - subject = create_subject() + subject = create_study_subject() redcap_subject = self.create_redcap_subject_from_smash_subject(subject) subject.date_born = get_today_midnight_date() @@ -87,7 +87,7 @@ class TestRedcapConnector(TestCase): def test_create_inconsistent_data_for_dead(self): prepare_test_redcap_connection() - subject = create_subject() + subject = create_study_subject() redcap_subject = self.create_redcap_subject_from_smash_subject(subject) subject.dead = not subject.dead @@ -98,7 +98,7 @@ class TestRedcapConnector(TestCase): language = Language.objects.create(name="xx") language.save() prepare_test_redcap_connection() - subject = create_subject() + subject = create_study_subject() redcap_subject = self.create_redcap_subject_from_smash_subject(subject) subject.languages.add(language) @@ -108,7 +108,7 @@ class TestRedcapConnector(TestCase): def test_create_inconsistent_data_for_language2(self): language = Language.objects.create(name="xx") prepare_test_redcap_connection() - subject = create_subject() + subject = create_study_subject() redcap_subject = self.create_redcap_subject_from_smash_subject(subject) redcap_subject.add_language(language) @@ -117,7 +117,7 @@ class TestRedcapConnector(TestCase): def test_create_inconsistent_data_for_mpower_id(self): prepare_test_redcap_connection() - subject = create_subject() + subject = create_study_subject() redcap_subject = self.create_redcap_subject_from_smash_subject(subject) subject.mpower_id = "105" @@ -126,7 +126,7 @@ class TestRedcapConnector(TestCase): def test_create_inconsistent_data_for_mpower_id_with_whitespace(self): prepare_test_redcap_connection() - subject = create_subject() + subject = create_study_subject() subject.mpower_id = "105" redcap_subject = self.create_redcap_subject_from_smash_subject(subject) @@ -203,7 +203,7 @@ class TestRedcapConnector(TestCase): def test_refresh_inconsistent_data(self): prepare_test_redcap_connection() - subject = create_subject() + subject = create_study_subject() # noinspection SpellCheckingInspection subject.nd_number = 'NDtest_external' subject.save() diff --git a/smash/web/tests/view/test_appointments.py b/smash/web/tests/view/test_appointments.py index 37fc2b76fd68cf2ee5b5d4adf69d0a3f275259b3..25f971cef295e65263ed72d9bf2f75bf9d9beb54 100644 --- a/smash/web/tests/view/test_appointments.py +++ b/smash/web/tests/view/test_appointments.py @@ -3,7 +3,7 @@ import logging from django.urls import reverse -from web.tests.functions import create_subject, create_visit, create_appointment, create_worker, create_flying_team, \ +from web.tests.functions import create_study_subject, create_visit, create_appointment, create_worker, create_flying_team, \ format_form_field from web.forms import AppointmentEditForm, SubjectEditForm from web.models import Appointment, StudySubject @@ -23,7 +23,7 @@ class AppointmentsViewTests(LoggedInTestCase): self.assertEqual(response.status_code, 200) def test_appointments_edit(self): - subject = create_subject() + subject = create_study_subject() visit = create_visit(subject) appointment = create_appointment(visit, when=datetime.datetime.now()) new_comment = 'new comment' @@ -91,7 +91,7 @@ class AppointmentsViewTests(LoggedInTestCase): self.assertEqual(Appointment.APPOINTMENT_STATUS_FINISHED, appointment_result.status) def test_save_appointments_edit_with_invalid_nd_number(self): - subject = create_subject() + subject = create_study_subject() visit = create_visit(subject) appointment = create_appointment(visit, get_today_midnight_date()) @@ -107,7 +107,7 @@ class AppointmentsViewTests(LoggedInTestCase): self.assertFalse(updated_subject.information_sent) def test_save_appointments_edit_with_valid_nd_number(self): - subject = create_subject() + subject = create_study_subject() visit = create_visit(subject) appointment = create_appointment(visit, get_today_midnight_date()) @@ -136,7 +136,7 @@ class AppointmentsViewTests(LoggedInTestCase): return form_data def test_subject_flying_team_location(self): - subject = create_subject() + subject = create_study_subject() visit = create_visit(subject) appointment = create_appointment(visit, get_today_midnight_date()) diff --git a/smash/web/tests/view/test_contact_attempt.py b/smash/web/tests/view/test_contact_attempt.py index 9bb40d7191ef127995ec1a01f2a9618c91547971..a240ce9721866421cfde0c5bfd463b159e119594 100644 --- a/smash/web/tests/view/test_contact_attempt.py +++ b/smash/web/tests/view/test_contact_attempt.py @@ -7,18 +7,18 @@ from web.forms import ContactAttemptEditForm from web.models import ContactAttempt from web.models.constants import CONTACT_TYPES_EMAIL from web.tests import LoggedInWithWorkerTestCase -from web.tests.functions import create_subject, create_contact_attempt, format_form_field +from web.tests.functions import create_study_subject, create_contact_attempt, format_form_field class ContactAttemptViewTests(LoggedInWithWorkerTestCase): def test_contact_attempt_add_get(self): - subject = create_subject() + subject = create_study_subject() response = self.client.get(reverse('web.views.contact_add', kwargs={'subject_id': subject.id})) self.assertContains(response, 'selected">{}'.format(self.worker), 1) self.assertContains(response, 'selected">{}'.format(subject), 1) def test_contact_attempt_add_post_valid(self): - subject = create_subject() + subject = create_study_subject() self.assertEqual(0, ContactAttempt.objects.filter(subject=subject).count()) now = datetime.datetime.now() now_aware = timezone.make_aware(now, timezone.get_default_timezone()) @@ -43,7 +43,7 @@ class ContactAttemptViewTests(LoggedInWithWorkerTestCase): self.assertContains(response, comment, 1) def test_contact_attempt_add_post_invalid(self): - subject = create_subject() + subject = create_study_subject() self.assertEqual(0, ContactAttempt.objects.filter(subject=subject).count()) contact_type = CONTACT_TYPES_EMAIL comment = "this is a comment" diff --git a/smash/web/tests/view/test_export.py b/smash/web/tests/view/test_export.py index 91e1462730506a790a59ad8885ce431c60210cdb..d1394128104a6ece78d90d9b2a75ce46213687b0 100644 --- a/smash/web/tests/view/test_export.py +++ b/smash/web/tests/view/test_export.py @@ -3,13 +3,13 @@ from django.urls import reverse from web.models import Appointment from web.tests import LoggedInTestCase -from web.tests.functions import create_subject, create_appointment, create_visit +from web.tests.functions import create_study_subject, create_appointment, create_visit from web.views.export import subject_to_row_for_fields, DROP_OUT_FIELD class TestExportView(LoggedInTestCase): def test_export_subjects_to_csv(self): - create_subject() + create_study_subject() response = self.client.get(reverse('web.views.export_to_csv', kwargs={'data_type': "subjects"})) self.assertEqual(response.status_code, 200) @@ -19,7 +19,7 @@ class TestExportView(LoggedInTestCase): self.assertEqual(response.status_code, 200) def test_export_subjects_to_excel(self): - create_subject() + create_study_subject() response = self.client.get(reverse('web.views.export_to_excel', kwargs={'data_type': "subjects"})) self.assertEqual(response.status_code, 200) @@ -29,7 +29,7 @@ class TestExportView(LoggedInTestCase): self.assertEqual(response.status_code, 200) def test_subject_to_row_for_fields_when_not_resigned(self): - subject = create_subject() + subject = create_study_subject() subject.resigned = False subject.save() @@ -37,7 +37,7 @@ class TestExportView(LoggedInTestCase): self.assertFalse(result[0]) def test_subject_to_row_for_fields_when_resigned(self): - subject = create_subject() + subject = create_study_subject() subject.resigned = True subject.save() @@ -45,7 +45,7 @@ class TestExportView(LoggedInTestCase): self.assertFalse(result[0]) def test_subject_to_row_for_fields_when_dropped_out(self): - subject = create_subject() + subject = create_study_subject() subject.resigned = True subject.save() diff --git a/smash/web/tests/view/test_notifications.py b/smash/web/tests/view/test_notifications.py index c2586124a76f713af2746ad99f1cf5063123c773..c4dddfab55ffbcc3b733c56d0d744d0d43849c1c 100644 --- a/smash/web/tests/view/test_notifications.py +++ b/smash/web/tests/view/test_notifications.py @@ -5,7 +5,7 @@ from django.contrib.auth.models import AnonymousUser from web.models import Appointment, Location, AppointmentTypeLink from web.tests import LoggedInTestCase from web.tests.functions import create_appointment, create_location, create_worker, create_appointment_type -from web.tests.functions import create_subject +from web.tests.functions import create_study_subject from web.tests.functions import create_visit from web.views.notifications import \ get_approaching_visits_for_mail_contact, \ @@ -29,7 +29,7 @@ class NotificationViewTests(LoggedInTestCase): def test_get_exceeded_visit_notifications_count(self): original_notification = get_visits_without_appointments_count(self.user) - subject = create_subject() + subject = create_study_subject() visit = create_visit(subject) visit.datetime_end = "2011-01-01" visit.save() @@ -41,7 +41,7 @@ class NotificationViewTests(LoggedInTestCase): def test_get_exceeded_visit_notifications_count_2(self): original_notification = get_visits_without_appointments_count(self.user) - subject = create_subject() + subject = create_study_subject() visit = create_visit(subject) visit.datetime_end = "2011-01-01" visit.is_finished = True @@ -53,7 +53,7 @@ class NotificationViewTests(LoggedInTestCase): def test_get_visits_without_appointments_count(self): original_notification = get_visits_without_appointments_count(self.user) - subject = create_subject() + subject = create_study_subject() create_visit(subject) notification = get_visits_without_appointments_count(self.user) @@ -97,7 +97,7 @@ class NotificationViewTests(LoggedInTestCase): def test_get_visits_without_appointments_count_2(self): appointment_type = create_appointment_type() original_notification = get_visits_without_appointments_count(self.user) - subject = create_subject() + subject = create_study_subject() visit = create_visit(subject) visit.appointment_types.add(appointment_type) visit.save() @@ -107,7 +107,7 @@ class NotificationViewTests(LoggedInTestCase): def test_get_visits_without_appointments_count_3(self): original_notification = get_visits_without_appointments_count(self.user) - subject = create_subject() + subject = create_study_subject() visit = create_visit(subject) appointment = create_appointment(visit) @@ -118,7 +118,7 @@ class NotificationViewTests(LoggedInTestCase): self.assertEquals(original_notification.count + 1, notification.count) def test_get_unfinished_visits_order(self): - subject = create_subject() + subject = create_study_subject() visit = create_visit(subject) visit.datetime_begin = get_today_midnight_date() + datetime.timedelta(days=-10) @@ -141,7 +141,7 @@ class NotificationViewTests(LoggedInTestCase): def test_get_approaching_visits_without_appointments_count(self): original_notification = get_approaching_visits_without_appointments_count(self.user) - subject = create_subject() + subject = create_study_subject() visit = create_visit(subject) visit.datetime_begin = get_today_midnight_date() + datetime.timedelta(days=2) visit.save() @@ -151,7 +151,7 @@ class NotificationViewTests(LoggedInTestCase): def test_get_approaching_visits_without_appointments_count_2(self): original_notification = get_approaching_visits_without_appointments_count(self.user) - subject = create_subject() + subject = create_study_subject() visit = create_visit(subject) visit.datetime_begin = get_today_midnight_date() + datetime.timedelta(days=2) visit.save() @@ -162,7 +162,7 @@ class NotificationViewTests(LoggedInTestCase): def test_get_approaching_visits_without_appointments_count_3(self): original_notification = get_approaching_visits_without_appointments_count(self.user) - subject = create_subject() + subject = create_study_subject() visit = create_visit(subject) visit.datetime_begin = get_today_midnight_date() + datetime.timedelta(days=2) visit.save() @@ -175,7 +175,7 @@ class NotificationViewTests(LoggedInTestCase): self.assertEquals(original_notification.count + 1, notification.count) def test_get_approaching_visits_without_appointments_order(self): - subject = create_subject() + subject = create_study_subject() visit = create_visit(subject) visit.datetime_begin = get_today_midnight_date() + datetime.timedelta(days=10) @@ -198,14 +198,14 @@ class NotificationViewTests(LoggedInTestCase): def test_get_subject_with_no_visit_notifications_count(self): original_notification = get_subject_with_no_visit_notifications_count(self.user) - create_subject() + create_study_subject() notification = get_subject_with_no_visit_notifications_count(self.user) self.assertEquals(original_notification.count + 1, notification.count) def test_get_subject_with_no_visit_notifications_count_2(self): original_notification = get_subject_with_no_visit_notifications_count(self.user) - subject = create_subject() + subject = create_study_subject() visit = create_visit(subject) visit.is_finished = True @@ -216,7 +216,7 @@ class NotificationViewTests(LoggedInTestCase): def test_get_subject_with_no_visit_notifications_count_3(self): original_notification = get_subject_with_no_visit_notifications_count(self.user) - subject = create_subject() + subject = create_study_subject() create_visit(subject) @@ -225,7 +225,7 @@ class NotificationViewTests(LoggedInTestCase): def test_get_subject_with_no_visit_notifications_count_4(self): original_notification = get_subject_with_no_visit_notifications_count(self.user) - subject = create_subject() + subject = create_study_subject() subject.dead = True subject.save() @@ -234,7 +234,7 @@ class NotificationViewTests(LoggedInTestCase): def test_get_subject_with_no_visit_notifications_count_5(self): original_notification = get_subject_with_no_visit_notifications_count(self.user) - subject = create_subject() + subject = create_study_subject() subject.resigned = True subject.save() @@ -243,7 +243,7 @@ class NotificationViewTests(LoggedInTestCase): def test_get_unfinished_appointments_count(self): original_notification = get_unfinished_appointments_count(self.user) - subject = create_subject() + subject = create_study_subject() visit = create_visit(subject) appointment = create_appointment(visit) appointment.datetime_when = "2011-01-01" @@ -255,7 +255,7 @@ class NotificationViewTests(LoggedInTestCase): def test_get_unfinished_appointments_count_2(self): original_notification = get_unfinished_appointments_count(self.user) - subject = create_subject() + subject = create_study_subject() visit = create_visit(subject) appointment = create_appointment(visit) appointment.datetime_when = "2011-01-01" @@ -266,7 +266,7 @@ class NotificationViewTests(LoggedInTestCase): self.assertEquals(original_notification.count, notification.count) def test_get_unfinished_appointments_order(self): - subject = create_subject() + subject = create_study_subject() visit = create_visit(subject) appointment = create_appointment(visit, get_today_midnight_date() + datetime.timedelta(days=-10)) @@ -290,7 +290,7 @@ class NotificationViewTests(LoggedInTestCase): create_location("l1") create_location("l2") original_notification = get_subject_with_no_visit_notifications_count(self.user) - create_subject() + create_study_subject() notification = get_subject_with_no_visit_notifications_count(self.user) self.assertEquals(original_notification.count + 1, notification.count) @@ -302,7 +302,7 @@ class NotificationViewTests(LoggedInTestCase): original_notification = get_subject_with_no_visit_notifications_count(worker) - subject = create_subject() + subject = create_study_subject() subject.default_location = create_location("l1") subject.save() @@ -317,7 +317,7 @@ class NotificationViewTests(LoggedInTestCase): def test_get_approaching_visits_for_mail_contact_count(self): original_notification = get_approaching_visits_for_mail_contact_count(self.user) - subject = create_subject() + subject = create_study_subject() visit = create_visit(subject) visit.datetime_begin = get_today_midnight_date() + datetime.timedelta(days=100) visit.save() @@ -327,7 +327,7 @@ class NotificationViewTests(LoggedInTestCase): def test_get_approaching_visits_for_mail_contact_count_2(self): original_notification = get_approaching_visits_for_mail_contact_count(self.user) - subject = create_subject() + subject = create_study_subject() visit = create_visit(subject) visit.datetime_begin = get_today_midnight_date() + datetime.timedelta(days=100) visit.save() @@ -338,7 +338,7 @@ class NotificationViewTests(LoggedInTestCase): def test_get_approaching_visits_for_mail_contact_count_3(self): original_notification = get_approaching_visits_for_mail_contact_count(self.user) - subject = create_subject() + subject = create_study_subject() visit = create_visit(subject) visit.datetime_begin = get_today_midnight_date() + datetime.timedelta(days=100) visit.save() @@ -352,7 +352,7 @@ class NotificationViewTests(LoggedInTestCase): def test_get_approaching_visits_for_mail_contact_count_4(self): original_notification = get_approaching_visits_for_mail_contact_count(self.user) - subject = create_subject() + subject = create_study_subject() visit = create_visit(subject) visit.datetime_begin = get_today_midnight_date() + datetime.timedelta(days=100) visit.post_mail_sent = True @@ -362,7 +362,7 @@ class NotificationViewTests(LoggedInTestCase): self.assertEquals(original_notification.count, notification.count) def test_get_approaching_visits_for_mail_contact_order(self): - subject = create_subject() + subject = create_study_subject() visit = create_visit(subject) visit.datetime_begin = get_today_midnight_date() + datetime.timedelta(days=110) @@ -386,7 +386,7 @@ class NotificationViewTests(LoggedInTestCase): def test_get_subjects_with_reminder_count(self): original_without_visit_notification = get_subject_with_no_visit_notifications_count(self.user) original_notification = get_subjects_with_reminder_count(self.user) - subject = create_subject() + subject = create_study_subject() subject.datetime_contact_reminder = get_today_midnight_date() + datetime.timedelta(days=-1) subject.save() @@ -399,7 +399,7 @@ class NotificationViewTests(LoggedInTestCase): def test_get_subjects_with_reminder_count_2(self): original_without_visit_notification = get_subject_with_no_visit_notifications_count(self.user) original_notification = get_subjects_with_reminder_count(self.user) - subject = create_subject() + subject = create_study_subject() subject.datetime_contact_reminder = get_today_midnight_date() + datetime.timedelta(hours=1) subject.save() @@ -412,7 +412,7 @@ class NotificationViewTests(LoggedInTestCase): def test_get_subjects_with_reminder_count_3(self): original_without_visit_notification = get_subject_with_no_visit_notifications_count(self.user) original_notification = get_subjects_with_reminder_count(self.user) - subject = create_subject() + subject = create_study_subject() subject.datetime_contact_reminder = get_today_midnight_date() + datetime.timedelta(days=2) subject.save() diff --git a/smash/web/tests/view/test_subjects.py b/smash/web/tests/view/test_subjects.py index 655c178a42a6830a7f451e5284b22dcd7a3a7b27..acb84c152061b9b4c1269c29a87d3fbdfdb8409a 100644 --- a/smash/web/tests/view/test_subjects.py +++ b/smash/web/tests/view/test_subjects.py @@ -7,7 +7,7 @@ from web.models import StudySubject from web.models.constants import SEX_CHOICES_MALE, SUBJECT_TYPE_CHOICES_CONTROL, SUBJECT_TYPE_CHOICES_PATIENT, \ COUNTRY_AFGHANISTAN_ID, COUNTRY_OTHER_ID from web.tests import LoggedInWithWorkerTestCase -from web.tests.functions import create_subject, create_visit, create_appointment, get_test_location +from web.tests.functions import create_study_subject, create_visit, create_appointment, get_test_location from web.views.notifications import get_today_midnight_date @@ -22,13 +22,13 @@ class SubjectsViewTests(LoggedInWithWorkerTestCase): self.assertEqual(response.status_code, 200) def test_render_subject_edit(self): - subject = create_subject() + subject = create_study_subject() response = self.client.get(reverse('web.views.subject_edit', kwargs={'id': subject.id})) self.assertEqual(response.status_code, 200) def test_render_subject_visit_details(self): - subject = create_subject() + subject = create_study_subject() visit = create_visit(subject) create_appointment(visit) @@ -37,14 +37,14 @@ class SubjectsViewTests(LoggedInWithWorkerTestCase): self.assertFalse("Add visit" in response.content) def test_render_subject_visit_details_without_visit(self): - subject = create_subject() + subject = create_study_subject() response = self.client.get(reverse('web.views.subject_visit_details', kwargs={'id': subject.id})) self.assertEqual(response.status_code, 200) self.assertTrue("Add visit" in response.content) def test_save_subject_edit_when_resigned_without_reason(self): - subject = create_subject() + subject = create_study_subject() form_subject = SubjectEditForm(instance=subject) form_data = {} for key, value in form_subject.initial.items(): @@ -60,7 +60,7 @@ class SubjectsViewTests(LoggedInWithWorkerTestCase): self.assertTrue("Resign reason cannot be empty" in response.content) def test_save_subject_edit(self): - subject = create_subject() + subject = create_study_subject() form_subject = SubjectEditForm(instance=subject) form_data = {} for key, value in form_subject.initial.items(): @@ -164,19 +164,19 @@ class SubjectsViewTests(LoggedInWithWorkerTestCase): "prefix should start by X as default location prefix is equal to 'X'") def test_render_subjects(self): - create_subject() + create_study_subject() response = self.client.get(reverse('web.views.subjects')) self.assertEqual(response.status_code, 200) def test_render_subjects_with_no_visit(self): - create_subject() + create_study_subject() response = self.client.get(reverse('web.views.subject_no_visits')) self.assertEqual(response.status_code, 200) def test_render_subjects_require_contact(self): - subject = create_subject() + subject = create_study_subject() subject.datetime_contact_reminder = get_today_midnight_date() + datetime.timedelta(days=-1) response = self.client.get(reverse('web.views.subject_require_contact')) diff --git a/smash/web/tests/view/test_visit.py b/smash/web/tests/view/test_visit.py index 217475e6822e106079f7fc52550b706bcddd3a55..c1c5cce75caddf873bacd72dd9767fa64974a71f 100644 --- a/smash/web/tests/view/test_visit.py +++ b/smash/web/tests/view/test_visit.py @@ -5,7 +5,7 @@ from django.urls import reverse from web.forms import VisitDetailForm, VisitAddForm from web.models import Visit from web.tests import LoggedInTestCase -from web.tests.functions import create_subject, create_visit, create_appointment, create_appointment_type +from web.tests.functions import create_study_subject, create_visit, create_appointment, create_appointment_type from web.views.notifications import get_today_midnight_date @@ -36,14 +36,14 @@ class VisitViewTests(LoggedInTestCase): self.assertNotContains(response, "error") def test_render_add_visit(self): - subject = create_subject() + subject = create_study_subject() response = self.client.get(reverse('web.views.visit_add', kwargs={'subject_id': subject.id})) self.assertEqual(response.status_code, 200) def test_save_add_visit(self): visit_count = Visit.objects.all().count() - subject = create_subject() + subject = create_study_subject() form = VisitAddForm() form_data = {}