Пример #1
0
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()
Пример #2
0
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)
Пример #3
0
def ventilation_control_simple(directory):
    ventilation = VentilationControl(22)

    dest_file = os.path.join(directory, 'ventilation_control_simple.json')
    with open(dest_file, 'w') as fp:
        json.dump(ventilation.to_dict(abridged=True), fp, indent=4)