diff --git a/smash/web/api_views/subject.py b/smash/web/api_views/subject.py index 7d4a979e4352ff230fb6d6a52ef7beb72bab533f..5a43f3924846ad29f1ec7337487630747822a37f 100644 --- a/smash/web/api_views/subject.py +++ b/smash/web/api_views/subject.py @@ -323,7 +323,7 @@ def types(request): def serialize_subject(study_subject): - location = location_to_str(study_subject.location) + location = location_to_str(study_subject.default_location) flying_team = flying_team_to_str(study_subject.flying_team) visits = Visit.objects.filter(subject=study_subject).order_by('visit_number') serialized_visits = [] diff --git a/smash/web/tests/api_views/test_subject.py b/smash/web/tests/api_views/test_subject.py index b3da6195882493d7c95980d006977720ebf2bb12..265caddf99aee951b3a3c9abb9ba7672d55f4d1e 100644 --- a/smash/web/tests/api_views/test_subject.py +++ b/smash/web/tests/api_views/test_subject.py @@ -8,6 +8,7 @@ from django.test import Client from django.test import TestCase from django.urls import reverse +from tests import LoggedInWithWorkerTestCase from web.api_views.subject import get_subjects_order, get_subjects_filtered, serialize_subject from web.models import StudySubject, Appointment, Study from web.models.constants import GLOBAL_STUDY_ID, SUBJECT_TYPE_CHOICES_PATIENT, SUBJECT_TYPE_CHOICES_CONTROL @@ -20,16 +21,10 @@ from web.views.notifications import get_today_midnight_date logger = logging.getLogger(__name__) -class TestApi(TestCase): +class TestSubjectApi(LoggedInWithWorkerTestCase): def setUp(self): + super(TestSubjectApi, self).setUp() self.study_subject = create_study_subject() - self.client = Client() - username = 'piotr' - password = 'top_secret' - self.user = User.objects.create_user( - username=username, email='jacob@bla', password=password) - self.worker = create_worker(self.user) - self.client.login(username=username, password=password) def test_cities(self): city_name = "some city"