def test_program_not_mutated_after_rendering(): """Creating and rendering a program should not mutate its dict representations.""" # Set some non-typical parameters program = Program( name="MyProgram", duration=5, min_reps=1, reps_per_exercise=31, round_to=10, rep_scaler_func=[0.99, 0.97, 0.96, 0.95, 0.98], intensity_scaler_func=[0.99, 0.97, 0.96, 0.95, 0.98], units="asdf", ) with program.Day("A"): program.DynamicExercise("Squats", start_weight=100, final_weight=113, max_reps=12) program_serialized = program.serialize() program.render() program_dict = program.to_dict() # Rendering the program should not change the serialization assert program.serialize() == program_serialized # Serializing and de-serializing should not change the program dict reprs program = Program.deserialize(program.serialize()) program.render() assert program.serialize() == program_serialized assert program_dict == program.to_dict()
def test_Program(self): """Serialize and deserialize should be equal.""" program = Program(name="Beginner 5x5", duration=4, intensity=85, units="kg", round_to=2.5, rep_scaler_func=[1, 1, 1, 1]) with program.Day("A"): program.DynamicExercise(name="Squat", start_weight=100) program.render() # Create a new program by serializing and deserializing new_program = Program.deserialize(program.serialize()) new_program.render() assert str(program) == str(new_program)