Exemplo n.º 1
0
def test_dict_to_object_load():
    """Test the dict_to_object method with Setpoint objects."""
    heat_setpt = ScheduleRuleset.from_constant_value(
        'Office Heating', 21, schedule_types.temperature)
    cool_setpt = ScheduleRuleset.from_constant_value(
        'Office Cooling', 24, schedule_types.temperature)
    setpoint = Setpoint('Office Setpoint', heat_setpt, cool_setpt)

    setpoint_dict = setpoint.to_dict()
    new_setpoint = dict_to_object(setpoint_dict)
    assert isinstance(new_setpoint, Setpoint)
Exemplo n.º 2
0
def test_setpoint_dict_methods():
    """Test the to/from dict methods."""
    simple_heat = ScheduleDay(
        'Simple Weekday HtgSetp', [18, 21, 18],
        [Time(0, 0), Time(9, 0), Time(17, 0)])
    simple_cool = ScheduleDay(
        'Simple Weekday ClgSetp', [28, 24, 28],
        [Time(0, 0), Time(9, 0), Time(17, 0)])
    heat_setpt = ScheduleRuleset('Office Heating', simple_heat, None,
                                 schedule_types.temperature)
    cool_setpt = ScheduleRuleset('Office Cooling', simple_cool, None,
                                 schedule_types.temperature)
    humid_setpt = ScheduleRuleset.from_constant_value('Office Humid', 30,
                                                      schedule_types.humidity)
    dehumid_setpt = ScheduleRuleset.from_constant_value(
        'Office Dehumid', 60, schedule_types.humidity)
    setpoint = Setpoint('Office Setpoint', heat_setpt, cool_setpt, humid_setpt,
                        dehumid_setpt)

    setp_dict = setpoint.to_dict()
    new_setpoint = Setpoint.from_dict(setp_dict)
    assert new_setpoint == setpoint
    assert setp_dict == new_setpoint.to_dict()