Skip to content
Snippets Groups Projects
Commit 5d427646 authored by Vegard Murvold Sporstøl's avatar Vegard Murvold Sporstøl
Browse files

add test for UC-3

parent 897fcdc1
No related branches found
No related tags found
1 merge request!7Task3
Pipeline #114410 passed
This commit is part of merge request !7. Comments created here will be created in the context of that merge request.
......@@ -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 ###
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment