From 5d4276463e91cde44237ff940b6ee22718fff136 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Vegard=20Sporst=C3=B8l?= <vegarms@stud.ntnu.no>
Date: Mon, 8 Mar 2021 13:19:36 +0100
Subject: [PATCH] add test for UC-3

---
 backend/secfit/workouts/tests.py | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/backend/secfit/workouts/tests.py b/backend/secfit/workouts/tests.py
index 1b7e201..d656a73 100644
--- a/backend/secfit/workouts/tests.py
+++ b/backend/secfit/workouts/tests.py
@@ -237,15 +237,20 @@ class UserAccessTestCase(TestCase):
 class CreateWorkoutForAthleteTestCase(TestCase):
     def setUp(self):
         self.client = APIClient()
-        self.user = User.objects.create(username="user",password="user")
-        self.client.force_authenticate(user=self.user)
+        self.coach = User.objects.create(username="coach",password="coach")
+        self.athlete = User.objects.create(username="athlete",password="athlete", coach=self.coach)
+        self.client.force_authenticate(user=self.coach)
         self.request = json.loads('{"name": "test", "date": "2021-03-06T18:00:00.000Z", "notes": "note", "visibility": "PU", "exercise_instances": [], "filename": []}')
 
     def test_createWorkoutAsCoach(self):
-        self.request["owner"] = "test"
+        self.request["owner"] = "athlete"
         request = self.client.post('/api/workouts/', json.dumps(self.request), content_type='application/json')
         self.assertEquals(request.status_code,201)
 
+    def test_checkCoach(self):
+        workout = Workout.objects.create(name="test", date="2021-03-02T18:00:00Z", notes="note", owner=self.athlete, visibility="PU")
+        self.assertEqual(self.athlete, workout.owner)
+
 
 
 ### Test categorize exercise ###
@@ -271,6 +276,10 @@ class CategorizeExerciseTestCase(TestCase):
         response = self.client.post("/api/exercises/", data)
         self.assertEqual(response.status_code, 201)
     
+    def test_checkCategorizedExercise(self):
+        exercise = Exercise.objects.create(name="test", description="test", category="Endurance", unit="kg")
+        self.assertEqual("Endurance", exercise.category)
+
 
 
 ### Test permission-classes in workout/permissions ###
-- 
GitLab