Self hosted FLOSS fitness/workout, nutrition and weight tracker
Don't test with python 2.6 anymore
Roland Geiderb64f2a213c07
diff --git a/.travis.yml b/.travis.ymlindex 5b2ebb3e7..b6fd85e25 100644--- a/.travis.yml+++ b/.travis.yml@@ -2,7 +2,6 @@ language: python# Python versions to testpython:- - "2.6"- "2.7"# Manually define here the combinations of django and db versions to testdiff --git a/wger/manager/models.py b/wger/manager/models.pyindex 0c0201334..f91e556ee 100644--- a/wger/manager/models.py+++ b/wger/manager/models.py@@ -35,6 +35,7 @@ from wger.exercises.models import Languagefrom wger.utils.helpers import disable_for_loaddatafrom wger.utils.cache import cache_mapper, reset_workout_canonical_form+from wger.utils.constants import TWOPLACESfrom wger.weight.models import WeightEntryfrom wger.utils.fields import Html5DateFieldfrom wger.utils.fields import Html5DecimalField@@ -860,7 +861,7 @@ by the US Department of Agriculture. It is extremely complete, with around# Any of the entries is missingrate = 0- return decimal.Decimal(str(rate)).quantize(decimal.Decimal('.01'))+ return decimal.Decimal(str(rate)).quantize(TWOPLACES)def calculate_activities(self):'''@@ -902,7 +903,7 @@ by the US Department of Agriculture. It is extremely complete, with around# Totaltotal = (sleep + work + sport + freetime) / 24.0- return decimal.Decimal(str(total)).quantize(decimal.Decimal('.01'))+ return decimal.Decimal(str(total)).quantize(TWOPLACES)def user_bodyweight(self, weight):'''diff --git a/wger/manager/tests/test_preferences.py b/wger/manager/tests/test_preferences.pyindex 0bb189921..8b3bd7a3a 100644--- a/wger/manager/tests/test_preferences.py+++ b/wger/manager/tests/test_preferences.py@@ -20,6 +20,7 @@ from django.core.urlresolvers import reversefrom django.contrib.auth.models import Userfrom wger.exercises.models import Language+from wger.utils.constants import TWOPLACESfrom wger.weight.models import WeightEntryfrom wger.manager.models import UserProfilefrom wger.manager.tests.testcase import WorkoutManagerTestCase@@ -283,19 +284,23 @@ class PreferencesCalculationsTestCase(WorkoutManagerTestCase):self.user_login('test')user = User.objects.get(pk=2)- self.assertEqual(user.userprofile.calculate_activities(), decimal.Decimal('1.57'))+ self.assertEqual(user.userprofile.calculate_activities(),+ decimal.Decimal(1.57).quantize(TWOPLACES))# Gender has no influenceuser.userprofile.gender = "2"- self.assertEqual(user.userprofile.calculate_activities(), decimal.Decimal('1.57'))+ self.assertEqual(user.userprofile.calculate_activities(),+ decimal.Decimal(1.57).quantize(TWOPLACES))# Change some of the parametersuser.userprofile.work_intensity = '3'- self.assertEqual(user.userprofile.calculate_activities(), decimal.Decimal('1.80'))+ self.assertEqual(user.userprofile.calculate_activities(),+ decimal.Decimal(1.80).quantize(TWOPLACES))user.userprofile.work_intensity = '2'user.userprofile.sport_intensity = '2'- self.assertEqual(user.userprofile.calculate_activities(), decimal.Decimal('1.52'))+ self.assertEqual(user.userprofile.calculate_activities(),+ decimal.Decimal(1.52).quantize(TWOPLACES))class UserProfileApiTestCase(ApiBaseResourceTestCase):diff --git a/wger/nutrition/models.py b/wger/nutrition/models.pyindex 92dd93905..e548296ee 100644--- a/wger/nutrition/models.py+++ b/wger/nutrition/models.py@@ -315,8 +315,8 @@ class Ingredient(models.Model):(self.fat * FAT_FACTOR))# Compare the values, but be generous- energy_upper = self.energy * (1 + (self.ENERGY_APPROXIMATION / Decimal('100.0')))- energy_lower = self.energy * (1 - (self.ENERGY_APPROXIMATION / Decimal('100.0')))+ energy_upper = self.energy * (1 + (self.ENERGY_APPROXIMATION / Decimal(100.0)))+ energy_lower = self.energy * (1 - (self.ENERGY_APPROXIMATION / Decimal(100.0)))#logger.debug("{0} > {1} > {2}".format(energy_upper, energy_calculated, energy_lower))if not ((energy_upper > energy_calculated) and (energy_calculated > energy_lower)):diff --git a/wger/nutrition/tests/test_bmi.py b/wger/nutrition/tests/test_bmi.pyindex a9744f6e2..e88f9a3d9 100644--- a/wger/nutrition/tests/test_bmi.py+++ b/wger/nutrition/tests/test_bmi.py@@ -18,6 +18,7 @@ import datetimefrom django.core.urlresolvers import reversefrom django.contrib.auth.models import User+from wger.utils.constants import TWOPLACESfrom wger.weight.models import WeightEntryfrom wger.manager.tests.testcase import WorkoutManagerTestCase@@ -47,9 +48,9 @@ class BmiTestCase(WorkoutManagerTestCase):'weight': 80})self.assertEqual(response.status_code, 200)bmi = json.loads(response.content)- self.assertEqual(decimal.Decimal(bmi['bmi']), decimal.Decimal('24.69'))- self.assertEqual(decimal.Decimal(bmi['weight']), decimal.Decimal('80'))- self.assertEqual(decimal.Decimal(bmi['height']), decimal.Decimal('180'))+ self.assertEqual(decimal.Decimal(bmi['bmi']), decimal.Decimal(24.69).quantize(TWOPLACES))+ self.assertEqual(decimal.Decimal(bmi['weight']), decimal.Decimal(80))+ self.assertEqual(decimal.Decimal(bmi['height']), decimal.Decimal(180))def test_automatic_weight_entry(self):'''diff --git a/wger/nutrition/tests/test_calories_calculator.py b/wger/nutrition/tests/test_calories_calculator.pyindex 6b8024694..a28773f31 100644--- a/wger/nutrition/tests/test_calories_calculator.py+++ b/wger/nutrition/tests/test_calories_calculator.py@@ -18,6 +18,7 @@ import datetimefrom django.core.urlresolvers import reversefrom django.contrib.auth.models import User+from wger.utils.constants import TWOPLACESfrom wger.weight.models import WeightEntryfrom wger.manager.tests.testcase import WorkoutManagerTestCase@@ -52,8 +53,9 @@ class CaloresCalculatorTestCase(WorkoutManagerTestCase):'freetime_intensity': 1})self.assertEqual(response.status_code, 200)result = json.loads(response.content)- self.assertEqual(decimal.Decimal(result['factor']), decimal.Decimal('1.57'))- self.assertEqual(decimal.Decimal(result['activities']), decimal.Decimal('2920'))+ self.assertEqual(decimal.Decimal(result['factor']),+ decimal.Decimal(1.57).quantize(TWOPLACES))+ self.assertEqual(decimal.Decimal(result['activities']), decimal.Decimal(2920))def test_automatic_weight_entry(self):'''diff --git a/wger/nutrition/tests/test_ingredient.py b/wger/nutrition/tests/test_ingredient.pyindex 23786f1e8..44a1ec82d 100644--- a/wger/nutrition/tests/test_ingredient.py+++ b/wger/nutrition/tests/test_ingredient.py@@ -273,14 +273,14 @@ class IngredientValuesTestCase(WorkoutManagerTestCase):self.assertEqual(response.status_code, 200)result = json.loads(response.content)self.assertEqual(len(result), 8)- self.assertEqual(result, {u'sodium': u'0.00549',+ self.assertEqual(result, {u'sodium': u'0.01',u'energy': u'1.76',- u'fat': u'0.0819',- u'carbohydrates_sugar': 0,- u'fat_saturated': u'0.03244',- u'fibres': 0,- u'protein': u'0.2563',- u'carbohydrates': u'0.00125'})+ u'fat': u'0.08',+ u'carbohydrates_sugar': u'0.00',+ u'fat_saturated': u'0.03',+ u'fibres': u'0.00',+ u'protein': u'0.26',+ u'carbohydrates': u'0.00'})# Get the nutritional values in 1 unit of productresponse = self.client.post(reverse('ingredient-get-values', kwargs={'pk': 1}),@@ -291,14 +291,14 @@ class IngredientValuesTestCase(WorkoutManagerTestCase):self.assertEqual(response.status_code, 200)result = json.loads(response.content)self.assertEqual(len(result), 8)- self.assertEqual(result, {u'sodium': u'0.612135',+ self.assertEqual(result, {u'sodium': u'0.61',u'energy': u'196.24',- u'fat': u'9.13185',- u'carbohydrates_sugar': 0,- u'fat_saturated': u'3.61706',- u'fibres': 0,- u'protein': u'28.57745',- u'carbohydrates': u'0.139375'})+ u'fat': u'9.13',+ u'carbohydrates_sugar': u'0.00',+ u'fat_saturated': u'3.62',+ u'fibres': u'0.00',+ u'protein': u'28.58',+ u'carbohydrates': u'0.14'})def test_calculate_value_anonymous(self):'''diff --git a/wger/nutrition/tests/test_nutritional_calculations.py b/wger/nutrition/tests/test_nutritional_calculations.pyindex f0ba48f46..4a85b922f 100644--- a/wger/nutrition/tests/test_nutritional_calculations.py+++ b/wger/nutrition/tests/test_nutritional_calculations.py@@ -74,7 +74,7 @@ class NutritionalValuesCalculationsTestCase(WorkoutManagerTestCase):for i in result_item:self.assertEqual(result_item[i],- (getattr(ingredient, i) * Decimal('12.0') / 100).quantize(TWOPLACES))+ (getattr(ingredient, i) * Decimal(12.0) / 100).quantize(TWOPLACES))result_meal = meal.get_nutritional_values()self.assertEqual(result_item, result_meal)@@ -117,7 +117,7 @@ class NutritionalValuesCalculationsTestCase(WorkoutManagerTestCase):for i in result_item3:self.assertEqual(result_item3[i],- (getattr(ingredient3, i) * Decimal('20.0') / 100).quantize(TWOPLACES))+ (getattr(ingredient3, i) * Decimal(20.0) / 100).quantize(TWOPLACES))result_total[i] = result_total[i] + result_item3[i]result_meal = meal.get_nutritional_values()diff --git a/wger/nutrition/tests/test_pdf.py b/wger/nutrition/tests/test_pdf.pyindex 3423b9006..44f95b648 100644--- a/wger/nutrition/tests/test_pdf.py+++ b/wger/nutrition/tests/test_pdf.py@@ -66,7 +66,7 @@ class NutritionalPlanPdfExportTestCase(WorkoutManagerTestCase):# Approximate sizeself.assertGreater(int(response['Content-Length']), 33300)- self.assertLess(int(response['Content-Length']), 33380)+ self.assertLess(int(response['Content-Length']), 33400)def test_export_pdf_anonymous(self):'''diff --git a/wger/software/templates/code.html b/wger/software/templates/code.htmlindex a7d565ec9..0900c3304 100644--- a/wger/software/templates/code.html+++ b/wger/software/templates/code.html@@ -244,7 +244,7 @@ the necessary packages and dependencies as described before.</p><ul><li><strong>Django:</strong> 1.4, 1.5, 1.6</li><li><strong>Databases:</strong> sqlite, mysql, postgres</li>- <li><strong>Python:</strong> 2.6, 2.7</li>+ <li><strong>Python:</strong> 2.7</li></ul><p>Setup any database