def test_training_is_saved_in_db(self): """Test if the training has been successfully saved in the database""" training = TrainingModel( name="test training", user_id=self.user.id, distance=10, time_in_seconds=3600, ) training.save_to_db() found_training = TrainingModel.find_by_name("test training") self.assertIsNotNone(found_training)
def _create_sample_training( cls, user: "******", name: str = "test", distance: int = 10, time_in_seconds=3600, ) -> "TrainingModel": """Create a sample training""" training = TrainingModel( name=name, user_id=user.id, distance=distance, time_in_seconds=time_in_seconds, ) training.calculate_average_tempo() training.save_to_db() return training