Self hosted FLOSS fitness/workout, nutrition and weight tracker
Add tests for the percent and the per_kg nutritional calculations
Roland Geiderf6277e6e6c54
diff --git a/wger/nutrition/tests/test_nutritional_calculations.py b/wger/nutrition/tests/test_nutritional_calculations.pyindex df5fd9344..f0ba48f46 100644--- a/wger/nutrition/tests/test_nutritional_calculations.py+++ b/wger/nutrition/tests/test_nutritional_calculations.py@@ -20,7 +20,6 @@ from wger.nutrition import modelsfrom wger.manager.tests.testcase import WorkoutManagerTestCasefrom wger.utils.constants import TWOPLACES-logger = logging.getLogger('wger.custom')@@ -126,3 +125,20 @@ class NutritionalValuesCalculationsTestCase(WorkoutManagerTestCase):result_plan = plan.get_nutritional_values()self.assertEqual(result_meal, result_plan['total'])++ def test_calculations_user(self):+ '''+ Tests the calculations+ :return:+ '''+ self.user_login('test')+ plan = models.NutritionPlan.objects.get(pk=4)+ values = plan.get_nutritional_values()++ self.assertEqual(values['percent']['carbohydrates'], Decimal(29.79).quantize(TWOPLACES))+ self.assertEqual(values['percent']['fat'], Decimal(20.36).quantize(TWOPLACES))+ self.assertEqual(values['percent']['protein'], Decimal(26.06).quantize(TWOPLACES))++ self.assertEqual(values['per_kg']['carbohydrates'], Decimal(4.81).quantize(TWOPLACES))+ self.assertEqual(values['per_kg']['fat'], Decimal(1.46).quantize(TWOPLACES))+ self.assertEqual(values['per_kg']['protein'], Decimal(4.21).quantize(TWOPLACES))