From bb60eac521535bcfb602bdc8be0baaa583654a39 Mon Sep 17 00:00:00 2001 From: Piotr Gawron <piotr.gawron@uni.lu> Date: Tue, 5 Dec 2017 17:13:29 +0100 Subject: [PATCH] invalid field reference fixed --- smash/web/api_views/subject.py | 2 +- smash/web/tests/api_views/test_subject.py | 11 +++-------- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/smash/web/api_views/subject.py b/smash/web/api_views/subject.py index 7d4a979e..5a43f392 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 b3da6195..265caddf 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" -- GitLab