Self hosted FLOSS fitness/workout, nutrition and weight tracker
fix tests
Lydia Xing0e715a2820ea
diff --git a/wger/exercises/tests/test_exercise.py b/wger/exercises/tests/test_exercise.pyindex 961ab983d..ffbffd0df 100644--- a/wger/exercises/tests/test_exercise.py+++ b/wger/exercises/tests/test_exercise.py@@ -38,6 +38,7 @@ from wger.exercises.models import ()from wger.utils.cache import cache_mapperfrom wger.utils.constants import WORKOUT_TAB+from wger.utils.helpers import random_stringclass ExerciseRepresentationTestCase(WgerTestCase):@@ -242,7 +243,7 @@ class ExercisesTestCase(WgerTestCase):count_before = Exercise.objects.count()response = self.client.post(reverse('exercise:exercise:add'),{'category': 2,- 'name_original': 'my test exercise',+ 'name_original': random_string(),'license': 1,'muscles': [1, 2]})count_after = Exercise.objects.count()@@ -293,9 +294,10 @@ class ExercisesTestCase(WgerTestCase):# Add an exercisecount_before = Exercise.objects.count()description = 'a nice, long and accurate description for the exercise'+ name_original = random_string()response = self.client.post(reverse('exercise:exercise:add'),{'category': 2,- 'name_original': 'my test exercise',+ 'name_original': name_original,'license': 1,'description': description,'muscles': [1, 2]})@@ -323,12 +325,12 @@ class ExercisesTestCase(WgerTestCase):self.assertEqual(response.context['active_tab'], WORKOUT_TAB)exercise_1 = Exercise.objects.get(pk=exercise_id)- self.assertEqual(exercise_1.name, 'my Test Exercise')+ self.assertEqual(exercise_1.name, name_original)# Wrong category - addingresponse = self.client.post(reverse('exercise:exercise:add'),{'category': 111,- 'name_original': 'my test exercise',+ 'name_original': random_string(),'license': 1,'muscles': [1, 2]})self.assertTrue(response.context['form'].errors['category'])@@ -336,7 +338,7 @@ class ExercisesTestCase(WgerTestCase):# Wrong category - editingresponse = self.client.post(reverse('exercise:exercise:edit', kwargs={'pk': '1'}),{'category': 111,- 'name_original': 'my test exercise',+ 'name_original': random_string(),'license': 1,'muscles': [1, 2]})if admin:@@ -347,7 +349,7 @@ class ExercisesTestCase(WgerTestCase):# No muscles - addingresponse = self.client.post(reverse('exercise:exercise:add'),{'category': 1,- 'name_original': 'my test exercise',+ 'name_original': random_string(),'license': 1,'muscles': []})self.assertEqual(response.status_code, 302)@@ -355,7 +357,7 @@ class ExercisesTestCase(WgerTestCase):# No muscles - editingresponse = self.client.post(reverse('exercise:exercise:edit', kwargs={'pk': '1'}),{'category': 1,- 'name_original': 'my test exercise',+ 'name_original': random_string(),'license': 1,'muscles': []})if admin:diff --git a/wger/utils/helpers.py b/wger/utils/helpers.pyindex ef6aff772..00babfe97 100644--- a/wger/utils/helpers.py+++ b/wger/utils/helpers.py@@ -263,3 +263,9 @@ def levenshtein(s1, s2):distances_.append(1 + min((distances[i1], distances[i1 + 1], distances_[-1])))distances = distances_return distances[-1]++def random_string(length=32):+ """+ Generates a random string+ """+ return ''.join(random.choice(string.ascii_uppercase) for i in range(length))