From 24ff6af3d295ac44967fac52c994b1189d7458a5 Mon Sep 17 00:00:00 2001
From: Piotr Gawron <piotr.gawron@uni.lu>
Date: Thu, 7 Dec 2017 15:28:22 +0100
Subject: [PATCH] common unit test initialization extracted

---
 smash/web/tests/api_views/test_appointment.py | 16 ++++------------
 1 file changed, 4 insertions(+), 12 deletions(-)

diff --git a/smash/web/tests/api_views/test_appointment.py b/smash/web/tests/api_views/test_appointment.py
index ddfa8eeb..84a79280 100644
--- a/smash/web/tests/api_views/test_appointment.py
+++ b/smash/web/tests/api_views/test_appointment.py
@@ -3,28 +3,20 @@
 import datetime
 import json
 
-from django.contrib.auth.models import User
-from django.test import Client
-from django.test import TestCase
 from django.urls import reverse
 
 from web.models import AppointmentTypeLink, AppointmentList
-from web.tests.functions import create_study_subject, create_worker, create_visit, create_appointment, \
+from web.tests import LoggedInWithWorkerTestCase
+from web.tests.functions import create_study_subject, create_visit, create_appointment, \
     create_appointment_type, create_get_suffix, create_flying_team
 from web.views.appointment import APPOINTMENT_LIST_GENERIC, APPOINTMENT_LIST_APPROACHING, APPOINTMENT_LIST_UNFINISHED
 from web.views.notifications import get_today_midnight_date
 
 
-class TestAppointmentApi(TestCase):
+class TestAppointmentApi(LoggedInWithWorkerTestCase):
     def setUp(self):
+        super(TestAppointmentApi, 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_appointments_valid(self):
         place = "Some new flying team location"
-- 
GitLab