Skip to content
Snippets Groups Projects

Task3

Merged Vegard Murvold Sporstøl requested to merge task3 into master
1 file
+ 12
3
Compare changes
  • Side-by-side
  • Inline
@@ -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 ###
Loading