def ventilation_control_detailed(directory): simple_flush = ScheduleDay('Simple Flush', [1, 0, 1], [Time(0, 0), Time(9, 0), Time(22, 0)]) schedule = ScheduleRuleset('Night Flush Schedule', simple_flush, None, schedule_types.fractional) ventilation = VentilationControl(22, 28, 12, 32, 0) ventilation.schedule = schedule dest_file = os.path.join(directory, 'ventilation_control_detailed.json') with open(dest_file, 'w') as fp: json.dump(ventilation.to_dict(abridged=True), fp, indent=4)
def test_ventilation_control_equality(): """Test the equality of VentilationControl objects.""" simple_office = ScheduleDay('Simple Flush', [1, 0, 1], [Time(0, 0), Time(9, 0), Time(22, 0)]) schedule = ScheduleRuleset('Night Flush Schedule', simple_office, None, schedule_types.fractional) ventilation = VentilationControl(18, schedule=schedule) ventilation_dup = ventilation.duplicate() ventilation_alt = VentilationControl(20) ventilation_alt.schedule = schedule assert ventilation is ventilation assert ventilation is not ventilation_dup assert ventilation == ventilation_dup ventilation_dup.delta_temperature = -2 assert ventilation != ventilation_dup assert ventilation != ventilation_alt
def test_ventilation_dict_methods(): """Test the to/from dict methods.""" simple_office = ScheduleDay('Simple Flush', [1, 0, 1], [Time(0, 0), Time(9, 0), Time(22, 0)]) schedule = ScheduleRuleset('Night Flush Schedule', simple_office, None, schedule_types.fractional) ventilation = VentilationControl(22, 28, 12, 32, 0) vent_dict = ventilation.to_dict() new_ventilation = VentilationControl.from_dict(vent_dict) assert new_ventilation == ventilation assert vent_dict == new_ventilation.to_dict() ventilation.schedule = schedule vent_dict = ventilation.to_dict() new_ventilation = VentilationControl.from_dict(vent_dict) assert new_ventilation == ventilation assert vent_dict == new_ventilation.to_dict()