def test_get_total_kilometers(self): """Test if correct total kilometers number is returned""" self._create_sample_training( user=self.user, name="test training1", distance=10 ) self._create_sample_training( user=self.user, name="test training2", distance=7 ) kilometers_number = TrainingModel.get_total_kilometers() expected_number = 17 self.assertEqual(kilometers_number, expected_number)
def get(cls): kilometers_number = TrainingModel.get_total_kilometers() return {"kilometers_number": kilometers_number}, 200