Self hosted FLOSS fitness/workout, nutrition and weight tracker
Read the hash value from the template, this is less error prone
Roland Geider8661dc66afac
diff --git a/wger/weight/tests/csv_import.py b/wger/weight/tests/csv_import.pyindex b1b68ff9f..471b66604 100644--- a/wger/weight/tests/csv_import.py+++ b/wger/weight/tests/csv_import.py@@ -1,25 +1,22 @@# 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 Licenseimport logging--from django.test import TestCasefrom django.core.urlresolvers import reversefrom wger.weight.models import WeightEntry-from wger.manager.tests.testcase import WorkoutManagerTestCaselogger = logging.getLogger('workout_manager.custom')@@ -29,20 +26,20 @@ class WeightCsvImportTestCase(WorkoutManagerTestCase):'''Test case for the CSV import for weight entries'''-- def import_csv(self, fail = False):++ def import_csv(self, fail=False):'''Helper function to test the CSV import'''response = self.client.get(reverse('weight-import-csv'))-+if fail:# There is a redirectself.assertEqual(response.status_code, 302)else:# Logged in users see a pageself.assertEqual(response.status_code, 200)-+# Do a direct post request# 1st stepcount_before = WeightEntry.objects.count()@@ -59,38 +56,44 @@ class WeightCsvImportTestCase(WorkoutManagerTestCase):{'stage': 1,'csv_input': csv_input,'date_format': '%d.%m.%y'})-+if fail:self.assertEqual(response.status_code, 302)-+ hash_value = ''+else:self.assertEqual(response.status_code, 200)self.assertEqual(len(response.context['weight_list']), 6)self.assertEqual(len(response.context['error_list']), 3)-+ hash_value = response.context['hash_value']+# 2nd. stepresponse = self.client.post(reverse('weight-import-csv'),{'stage': 2,- 'hash': 'fde7e06185aad7151b8c93ee961499ebabb7983d',+ 'hash': hash_value,'csv_input': csv_input,'date_format': '%d.%m.%y'})-+count_after = WeightEntry.objects.count()self.assertEqual(response.status_code, 302)-+if fail:self.assertEqual(count_before, count_after)else:self.assertGreater(count_after, count_before)def test_import_csv_anonymous(self):- """Test deleting a category by an unauthorized user"""-+ '''+ Test deleting a category by an unauthorized user+ '''+self.import_csv(fail=True)-+def test_import_csv_loged_in(self):- """Test deleting a category by a logged in user"""-+ '''+ Test deleting a category by a logged in user+ '''+self.user_login('test')self.import_csv(fail=False)-+