Example #1
0
 def test_single_set_create_sets(self, patcher):
     mock_workout = Workout(workout_text="Bench: 225x5+2")
     mock_workout.save()
     w = WorkoutLogParser(mock_workout)
     w.parse()
     self.assertEqual(w.create_single_set.call_count, 1)
     self.assertTrue(w.create_single_set.called_with("Bench", "225x5+2"))
Example #2
0
	def test_multi_line_parse_line(self,patcher):
		mock_workout = Workout(workout_text = "Exercise 1: 12#x5, #18x10 \\r\\n\\r Exercise 2: 2x4x3+2\\r\\n\\rComments")
		mock_workout.save()
		w = WorkoutLogParser(mock_workout)
		w.parse()
		self.assertEqual(w.create_sets.call_count,3)
		self.assertEqual(mock_workout.comments,r'\nComments')
Example #3
0
	def test_create_single_set_with_parenthesis(self):
		text="Chin up with 3 second hang + Tricep Rope Pulldowns: BWx4+#4x10, 3x(BWx3 + #5x10)"
		mock_workout = Workout(workout_text=text)
		mock_workout.save()
		parser = WorkoutLogParser(mock_workout)
		parser.parse()
		self.assertTrue(mock_workout.sets.first().exerciseName == "Chin up with 3 second hang + Tricep Rope Pulldowns")
Example #4
0
 def test_with_html_markup(self):
     text = "Ohp: <b>62x2x5"
     mock_workout = Workout(workout_text=text)
     mock_workout.save()
     parser = WorkoutLogParser(mock_workout)
     parser.parse()
     for _set in mock_workout.sets.all():
         self.assertTrue(_set.exerciseName == "Ohp")
         self.assertTrue(_set.weight == 62)
         self.assertTrue(_set.reps == 5)
def parse_sets():
	workout_to_sets = {}
	for w in Workout.objects.all():
		parser = WorkoutLogParser(w)
		try:
			sets = parser.parse()
		except Exception as e:
			print("couldn't parse log " + str(w.id))
			print(e)
		workout_to_sets[w.id] = sets	
	return workout_to_sets
Example #6
0
    def test_multi_set_create_sets(self, patcher):
        exercise_name = 'Bench + Accessory'
        sets = "135x5x1+6"
        mock_workout = Workout(workout_text=exercise_name + ":" + sets)
        mock_workout.save()
        w = WorkoutLogParser(mock_workout)
        w.parse()
        self.assertEqual(w.create_single_set.call_count, 5)
        self.assertTrue(w.create_single_set.called_with(exercise_name, sets))

        for _call in w.create_single_set.call_list():
            self.assertEqual(_call.call_args[0], exercise_name)
            self.assertEqual(_call.call_args[1], "135x1+6")
Example #7
0
 def test_split_lines(self):
     mock_workout = Workout()
     mock_workout.save()
     text = "Line 1 \\r\\n\\r Line 2, skip 3 \\n\\nLine 4 \\r\\n\\r Line 5"
     w = WorkoutLogParser(mock_workout)
     self.assertEqual(len(w.split_by_line(text)), 5)
Example #8
0
 def test_create_sets_with_5x5_should_create_1_set(self, patcher):
     mock_workout = Workout(workout_text="Bench: 225x5")
     mock_workout.save()
     w = WorkoutLogParser(mock_workout)
     w.parse()
     self.assertEqual(w.create_single_set.call_count, 1)
Example #9
0
 def test_with_nonLbsOrKg_in_weight_zone(self):
     text = "Banded side steps: grnx3x8\\n\\nsingle leg glute bridge: bwx3x8\\n\\nClean and Jerk: 40x2, 60x2, 60x2, 70x2, 80, 85, 90, 95, 100\\n\\nFs: 70x3, 80x3, 90x3, 100x2x2\\n\\nRdl: 90x3x4\\n\\nPause Ab wheel: bwx3x10\\nWas really able to stay upright and drive through my glutes in the front squats"
     mock_workout = Workout(workout_text=text)
     mock_workout.save()
     parser = WorkoutLogParser(mock_workout)
     parser.parse()