Self hosted FLOSS fitness/workout, nutrition and weight tracker
Add a fixture with workout test data, update tests
Roland Geidere64ef89c7f50
diff --git a/manager/fixtures/tests-workout-data.json b/manager/fixtures/tests-workout-data.jsonnew file mode 100644index 000000000..685802a12--- /dev/null+++ b/manager/fixtures/tests-workout-data.json@@ -0,0 +1,147 @@+[+ {+ "pk": 1,+ "model": "manager.trainingschedule",+ "fields": {+ "comment": "A test workout",+ "user": 1,+ "creation_date": "2012-11-01"+ }+ },+ {+ "pk": 2,+ "model": "manager.trainingschedule",+ "fields": {+ "comment": "Another test workout",+ "user": 1,+ "creation_date": "2012-11-10"+ }+ },+ {+ "pk": 3,+ "model": "manager.trainingschedule",+ "fields": {+ "comment": "My test workout",+ "user": 2,+ "creation_date": "2012-11-20"+ }+ },+++ {+ "pk": 1,+ "model": "manager.day",+ "fields": {+ "training": 1,+ "description": "A day",+ "day": [+ 2+ ]+ }+ },+ {+ "pk": 2,+ "model": "manager.day",+ "fields": {+ "training": 1,+ "description": "Another day",+ "day": [+ 4+ ]+ }+ },+ {+ "pk": 1,+ "model": "manager.set",+ "fields": {+ "exercises": [+ 1+ ],+ "exerciseday": 1,+ "order": 1,+ "sets": "2"+ }+ },+ {+ "pk": 2,+ "model": "manager.set",+ "fields": {+ "exercises": [+ 2+ ],+ "exerciseday": 2,+ "order": 1,+ "sets": "4"+ }+ },+ {+ "pk": 1,+ "model": "manager.setting",+ "fields": {+ "comment": "",+ "set": 1,+ "reps": 8,+ "order": 1,+ "exercise": 1+ }+ },+ {+ "pk": 2,+ "model": "manager.setting",+ "fields": {+ "comment": "",+ "set": 2,+ "reps": 10,+ "order": 1,+ "exercise": 2+ }+ },+ {+ "pk": 1,+ "model": "manager.workoutlog",+ "fields": {+ "weight": 30,+ "workout": 1,+ "reps": 8,+ "user": 1,+ "date": "2012-10-01",+ "exercise": 1+ }+ },+ {+ "pk": 2,+ "model": "manager.workoutlog",+ "fields": {+ "weight": 32,+ "workout": 1,+ "reps": 8,+ "user": 1,+ "date": "2012-10-10",+ "exercise": 1+ }+ },+ {+ "pk": 3,+ "model": "manager.workoutlog",+ "fields": {+ "weight": 38,+ "workout": 1,+ "reps": 8,+ "user": 1,+ "date": "2012-10-30",+ "exercise": 1+ }+ },+ {+ "pk": 1,+ "model": "manager.workoutlog",+ "fields": {+ "weight": 30,+ "workout": 1,+ "reps": 8,+ "user": 1,+ "date": "2012-11-01",+ "exercise": 1+ }+ }+]diff --git a/manager/tests/index.py b/manager/tests/index.pyindex e129b50cd..b8789ecef 100644--- a/manager/tests/index.py+++ b/manager/tests/index.py@@ -42,10 +42,10 @@ class DashboardTestCase(WorkoutManagerTestCase):# Correct tab is selectedself.assertEqual(response.context['active_tab'], 'user')- # There is nothing else to send to the template- self.assertEqual(response.context['weight'], False)- self.assertEqual(response.context['current_workout'], False)- self.assertEqual(response.context['plan'], False)+ # Check data sent to the template+ self.assertFalse(response.context['weight'])+ self.assertTrue(response.context['current_workout'])+ self.assertFalse(response.context['plan'])else:# Anonymous users are redirected to the login pagediff --git a/manager/tests/testcase.py b/manager/tests/testcase.pyindex 4012283b9..0d45d43e8 100644--- a/manager/tests/testcase.py+++ b/manager/tests/testcase.py@@ -21,10 +21,11 @@ from selenium import webdriverfrom selenium.webdriver.common.keys import Keysclass WorkoutManagerTestCase(TestCase):- fixtures = ['tests-user-data',+ fixtures = ('tests-user-data','test-exercises','tests-ingredients',- 'tests-days-of-week']+ 'tests-days-of-week',+ 'tests-workout-data')def user_login(self, user='admin'):"""Login the user, by default as 'admin'@@ -42,10 +43,10 @@ class WorkoutManagerLiveServerTestCase(LiveServerTestCase):Live server test case, will be used with the selenium webdriver"""- fixtures = ['tests-user-data',+ fixtures = ('tests-user-data','test-exercises','tests-ingredients',- 'tests-days-of-week']+ 'tests-days-of-week')def setUp(self):diff --git a/manager/tests/workout.py b/manager/tests/workout.pyindex e178da6cd..6975fd70a 100644--- a/manager/tests/workout.py+++ b/manager/tests/workout.py@@ -40,7 +40,7 @@ class AddWorkoutTestCase(WorkoutManagerTestCase):if not logged_in:self.assertEqual(count_before, count_after)- self.assertEqual(count_after, 0)+ self.assertEqual(count_after, 3)self.assertTemplateUsed('login.html')else:@@ -91,8 +91,8 @@ class WorkoutOverviewTestCase(WorkoutManagerTestCase):self.assertEqual(response.status_code, 302)return- # No data sent to the template- self.assertFalse(response.context['workouts'])+ # There are workouts sent to the template+ self.assertTrue(response.context['workouts'])def test_dashboard_anonymous(self):