Self hosted FLOSS fitness/workout, nutrition and weight tracker
Add first version of test case for nutritional plans
Roland Geidere0b690a2e3ed
diff --git a/wger/manager/tests/testcase.py b/wger/manager/tests/testcase.pyindex 30e3644c9..9a52153f9 100644--- a/wger/manager/tests/testcase.py+++ b/wger/manager/tests/testcase.py@@ -25,12 +25,12 @@ from selenium.webdriver.common.keys import Keysclass WorkoutManagerTestCase(TestCase):- fixtures = ('tests-user-data',+ fixtures = ('days_of_week',+ 'tests-user-data','test-weight-data','test-exercises','tests-ingredients','test-nutrition-data',- 'days_of_week','tests-workout-data')def setUp(self):@@ -85,7 +85,7 @@ class WorkoutManagerDeleteTestCase(WorkoutManagerTestCase):response = self.client.get(reverse(self.delete_url, kwargs={'pk': self.pk}))count_after = self.delete_class.objects.count()self.assertEqual(count_before, count_after)-+if fail:self.assertIn(response.status_code, (403, 302))else:@@ -166,7 +166,7 @@ class WorkoutManagerEditTestCase(WorkoutManagerTestCase):response = self.client.post(reverse(self.edit_url, kwargs={'pk': self.pk}),self.data_update)- entry_after = self.object_class.objects.get(pk=1)+ entry_after = self.object_class.objects.get(pk=self.pk)# Check the resultsif fail:@@ -247,7 +247,7 @@ class WorkoutManagerAddTestCase(WorkoutManagerTestCase):self.object_class.objects.get,pk=self.pk)self.assertEqual(count_before, count_after)-+else:self.assertEqual(response.status_code, 302)entry = self.object_class.objects.get(pk=self.pk)@@ -255,7 +255,6 @@ class WorkoutManagerAddTestCase(WorkoutManagerTestCase):self.assertEqual(getattr(entry, i), self.data[i])self.assertEqual(count_before + 1, count_after)-def test_add_object_anonymous(self):'''diff --git a/wger/nutrition/fixtures/test-nutrition-data.json b/wger/nutrition/fixtures/test-nutrition-data.jsonindex c24447b1c..3f2349b41 100644--- a/wger/nutrition/fixtures/test-nutrition-data.json+++ b/wger/nutrition/fixtures/test-nutrition-data.json@@ -3,7 +3,7 @@"pk": 9,"model": "nutrition.nutritionplan","fields": {- "description": "",+ "description": "Description 1","user": 1,"language": 2,"creation_date": "2012-11-19"@@ -13,7 +13,7 @@"pk": 8,"model": "nutrition.nutritionplan","fields": {- "description": "",+ "description": "My plan to do xyz","user": 1,"language": 2,"creation_date": "2012-11-12"diff --git a/wger/nutrition/tests/__init__.py b/wger/nutrition/tests/__init__.pyindex 0ed1ce6a2..636b9e74b 100644--- a/wger/nutrition/tests/__init__.py+++ b/wger/nutrition/tests/__init__.py@@ -1 +1,2 @@from wger.nutrition.tests.ingredient import *+from wger.nutrition.tests.plan import *diff --git a/wger/nutrition/tests/plan.py b/wger/nutrition/tests/plan.pynew file mode 100644index 000000000..1eaf1aed4--- /dev/null+++ b/wger/nutrition/tests/plan.py@@ -0,0 +1,41 @@+# This file is part of Workout Manager.+#+# Workout Manager is free software: you can redistribute it and/or modify+# it under the terms of the GNU Affero General Public License as published by+# the Free Software Foundation, either version 3 of the License, or+# (at your option) any later version.+#+# Workout Manager is distributed in the hope that it will be useful,+# but WITHOUT ANY WARRANTY; without even the implied warranty of+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+# GNU General Public License for more details.+#+# You should have received a copy of the GNU Affero General Public License+# along with Workout Manager. If not, see <http://www.gnu.org/licenses/>.++from wger.nutrition.models import NutritionPlan++from wger.manager.tests.testcase import WorkoutManagerDeleteTestCase+from wger.manager.tests.testcase import WorkoutManagerEditTestCase+from wger.manager.tests.testcase import WorkoutManagerAddTestCase+++class DeletePlanTestCase(WorkoutManagerDeleteTestCase):+ '''+ Tests deleting a nutritional plan+ '''++ delete_class = NutritionPlan+ delete_url = 'nutrition-delete'+ pk = 6+++class EditPlanTestCase(WorkoutManagerEditTestCase):+ '''+ Tests editing an ingredient+ '''++ object_class = NutritionPlan+ edit_url = 'nutrition-edit'+ pk = 6+ data_update = {'description': 'My new description'}