def test_when_bIsActive_is_false_then_state_bIsActive_false(self): "Check that the bIsActive is correctly set to false" self.raw_json["bIsActive"] = 0 genius_zone = GeniusZone(self._device_id, self.raw_json, self.hub) self.assertFalse(genius_zone.data["_state"]["bIsActive"])
def test_when_bOutRequestHeat_is_true_then_output_true(self): "Check that the bOutRequestHeat is correctly set to true" self.raw_json["bOutRequestHeat"] = 1 genius_zone = GeniusZone(self._device_id, self.raw_json, self.hub) self.assertEqual(genius_zone.data["output"], 1)
def test_when_timer_schedule_parsed_then_timer_schedule_has_seven_days( self): "Check that the timer schedule has seven days of data" genius_zone = GeniusZone(self._device_id, self.raw_json, self.hub) days = genius_zone.data["schedule"]["timer"]["weekly"] self.assertEqual(len(days), 7)
def test_when_timer_schedule_parsed_then_timer_schedule_first_day_has_2_heating_periods( self): # noqa: E501 "Check that the first day of the timer schedule has 2 heating periods" genius_zone = GeniusZone(self._device_id, self.raw_json, self.hub) day = genius_zone.data["schedule"]["timer"]["weekly"]["sunday"] heating_periods = day["heatingPeriods"] self.assertEqual(len(heating_periods), 2)
def test_when_override_applicable_for_iType_set_and_setpoint_is_not_zero_then_override_setpoint_is_true( self): # noqa: E501 "Check that the override property is not set to None" self.raw_json["iType"] = ZONE_TYPE.OnOffTimer self.raw_json["iBoostTimeRemaining"] = self._override_duration self.raw_json["fBoostSP"] = self._override_setpoint genius_zone = GeniusZone(self._device_id, self.raw_json, self.hub) self.assertTrue(genius_zone.data["override"]["setpoint"])
def test_when_timer_schedule_parsed_then_timer_schedule_first_day_first_heating_period_has_correct_end( self): # noqa: E501 """Check that the first heating period of the first day of the timer schedule has the correct end time set""" genius_zone = GeniusZone(self._device_id, self.raw_json, self.hub) day = genius_zone.data["schedule"]["timer"]["weekly"]["sunday"] heating_period = day["heatingPeriods"][0] self.assertEqual(heating_period["end"], self._heating_period_end)
def test_when_next_heating_period_does_not_have_start_time_then_timer_schedule_first_day_second_heating_period_has_default_end( self): # noqa: E501 """Check that the last heating period of the first day of the timer schedule has the end time set to end of day when next heating periodhas -1 start time""" genius_zone = GeniusZone(self._device_id, self.raw_json, self.hub) day = genius_zone.data["schedule"]["timer"]["weekly"]["sunday"] heating_period = day["heatingPeriods"][1] self.assertEqual(heating_period["end"], 86400)
def test_when_last_setpoint_then_timer_schedule_last_day_last_heating_period_has_default_end( self): # noqa: E501 """Check that the last heating period of the last day of the timer schedule has the correct end time set""" genius_zone = GeniusZone(self._device_id, self.raw_json, self.hub) day = genius_zone.data["schedule"]["timer"]["weekly"]["saturday"] heating_period = day["heatingPeriods"][0] self.assertEqual(heating_period["end"], 86400)
def test_when_iType_OnOffTimer_fSP_zero_setpoint_state_setpoint_set_false( self): """Check that the setpoint is set to false when iType is OnOffTimer and fSP is zero""" self.raw_json["fSP"] = 0.0 self.raw_json["iType"] = ZONE_TYPE.OnOffTimer genius_zone = GeniusZone(self._device_id, self.raw_json, self.hub) self.assertFalse(genius_zone.data["setpoint"])
def test_when_timer_schedule_parsed_then_timer_schedule_has_seven_days_named_correctly( self): # noqa: E501 "Check that the timer schedule has seven days of data" for day_int, day_text in IDAY_TO_DAY.items(): with self.subTest(day_int=day_int, day_text=day_text): genius_zone = GeniusZone(self._device_id, self.raw_json, self.hub) days = genius_zone.data["schedule"]["timer"]["weekly"] self.assertTrue(day_text in days)
def test_when_iMode_set_then_state_mode_is_set_correctly(self): "Check that the mode is set on the class" for zone_mode, zone_mode_text in IMODE_TO_MODE.items(): with self.subTest(zone_mode=zone_mode, zone_mode_text=zone_mode_text): self.raw_json["iMode"] = zone_mode self.raw_json["zoneSubType"] = 1 genius_zone = GeniusZone(self._device_id, self.raw_json, self.hub) self.assertEqual(genius_zone.data["mode"], zone_mode_text)
def test_when_trigger_reactive_false_then_is_occupied_false(self): "Check that is_occupied is false when the zone trigger reactive is set to false" # These values would set is_occupied to true self.raw_json["iFlagExpectedKit"] = ZONE_KIT.PIR self.raw_json["objFootprint"]["bIsNight"] = 0 self.raw_json["trigger"]["output"] = 1 self.raw_json["zoneReactive"]["fActivityLevel"] = 0.0 self.raw_json["trigger"]["reactive"] = 0 genius_zone = GeniusZone(self._device_id, self.raw_json, self.hub) self.assertFalse(genius_zone.data["occupied"])
def test_when_all_conditions_correct_then_occupied_true(self): "Check that when all the conditions are met, is_occupied is true" # These values would set is_occupied to true self.raw_json["iFlagExpectedKit"] = ZONE_KIT.PIR self.raw_json["objFootprint"]["bIsNight"] = 0 self.raw_json["trigger"]["reactive"] = 1 self.raw_json["trigger"]["output"] = 1 self.raw_json["zoneReactive"]["fActivityLevel"] = 1.0 genius_zone = GeniusZone(self._device_id, self.raw_json, self.hub) self.assertTrue(genius_zone.data["occupied"])
def test_when_override_not_applicable_for_iType_set_then_override_is_none( self): # noqa: E501 "Check that the override property is set to None" test_values = { ZONE_TYPE.Manager, ZONE_TYPE.ControlOnOffPID, ZONE_TYPE.Surrogate } for zone_type in test_values: with self.subTest(zone_type=zone_type): self.raw_json["iType"] = zone_type genius_zone = GeniusZone(self._device_id, self.raw_json, self.hub) self.assertFalse("override" in genius_zone.data)
def test_when_zone_does_not_have_room_sensor_then_occupied_missing(self): """Check that occupied is not in the data JSON when the zone does not have a room sensor""" # These values would set is_occupied to true self.raw_json["objFootprint"]["bIsNight"] = 0 self.raw_json["trigger"]["reactive"] = 1 self.raw_json["trigger"]["output"] = 1 self.raw_json["zoneReactive"]["fActivityLevel"] = 1.0 self.raw_json["iFlagExpectedKit"] = ZONE_KIT.Valve genius_zone = GeniusZone(self._device_id, self.raw_json, self.hub) self.assertTrue("occupied" not in genius_zone.data)
def test_when_iType_should_not_set_setpoint_state_setpoint_not_set(self): "Check that the setpoint is not set for certain values of iType" self.raw_json["fSP"] = 21.0 test_values = (ZONE_TYPE.Manager, ZONE_TYPE.ControlOnOffPID, ZONE_TYPE.Surrogate) for zone_type in test_values: with self.subTest(zone_type=zone_type): self.raw_json["iType"] = zone_type genius_zone = GeniusZone(self._device_id, self.raw_json, self.hub) self.assertFalse("setpoint" in genius_zone.data)
def test_when_iType_should_set_setpoint_state_setpoint_set_correctly(self): "Check that the setpoint is set for certain values of iType" setpoint = 21.0 self.raw_json["fSP"] = setpoint test_values = (ZONE_TYPE.ControlSP, ZONE_TYPE.TPI) for zone_type in test_values: with self.subTest(zone_type=zone_type): self.raw_json["iType"] = zone_type genius_zone = GeniusZone(self._device_id, self.raw_json, self.hub) self.assertEqual(genius_zone.data["setpoint"], setpoint)
def test_when_override_applicable_for_iType_set_and_setpoint_is_zero_then_override_is_none( self): # noqa: E501 "Check that the override property is not set to None" test_values = { ZONE_TYPE.OnOffTimer, ZONE_TYPE.ControlSP, ZONE_TYPE.TPI } for zone_type in test_values: with self.subTest(zone_type=zone_type): self.raw_json["iType"] = zone_type self.raw_json["iBoostTimeRemaining"] = 0 genius_zone = GeniusZone(self._device_id, self.raw_json, self.hub) self.assertTrue("override" in genius_zone.data)
def test_when_override_applicable_for_iType_set_and_setpoint_is_not_zero_then_override_setpoint_is_set( self): # noqa: E501 "Check that the override property is not set to None" test_values = {ZONE_TYPE.ControlSP, ZONE_TYPE.TPI} for zone_type in test_values: with self.subTest(zone_type=zone_type): self.raw_json["iType"] = zone_type self.raw_json["iBoostTimeRemaining"] = self._override_duration self.raw_json["fBoostSP"] = self._override_setpoint genius_zone = GeniusZone(self._device_id, self.raw_json, self.hub) override_setpoint = genius_zone.data["override"]["setpoint"] self.assertEqual(override_setpoint, self._override_setpoint)
def test_when_iType_should_not_set_temperature_state_temperature_not_set( self): "Check that the temperature is not set for certain values of iType" self.raw_json["fPV"] = 20.0 test_values = (ZONE_TYPE.OnOffTimer, ZONE_TYPE.ControlOnOffPID, ZONE_TYPE.Surrogate) for zone_type in test_values: with self.subTest(zone_type=zone_type): self.raw_json["iType"] = zone_type genius_zone = GeniusZone(self._device_id, self.raw_json, self.hub) self.assertFalse("temperature" in genius_zone.data)
def test_when_iType_should_set_temperature_state_temperature_set_correctly( self): "Check that the temperature is set for certain values of iType" temperature = 20.0 self.raw_json["fPV"] = temperature test_values = (ZONE_TYPE.ControlSP, ZONE_TYPE.TPI, ZONE_TYPE.Manager) for zone_type in test_values: with self.subTest(zone_type=zone_type): self.raw_json["iType"] = zone_type genius_zone = GeniusZone(self._device_id, self.raw_json, self.hub) self.assertEqual(genius_zone.data["temperature"], temperature)
def test_when_footprint_reactive_activity_level_zero_then_is_occupied_false( self): """Check that is_occupied is false when the zone footprint reactive activity level is not above zero""" # These values would set is_occupied to true self.raw_json["iFlagExpectedKit"] = ZONE_KIT.PIR self.raw_json["objFootprint"]["bIsNight"] = 0 self.raw_json["trigger"]["reactive"] = 1 self.raw_json["trigger"]["output"] = 1 self.raw_json["zoneReactive"]["fActivityLevel"] = 0.0 genius_zone = GeniusZone(self._device_id, self.raw_json, self.hub) self.assertFalse(genius_zone.data["occupied"])
def test_id_is_set_correctly_test(self): "Check that the id is set on the data object" genius_zone = GeniusZone(self._device_id, self.raw_json, self.hub) self.assertEqual(genius_zone.data['id'], self._device_id)
def test_name_is_set_correctly(self): "Check that the name is set on the data object" genius_zone = GeniusZone(self._device_id, self.raw_json, self.hub) self.assertEqual(genius_zone.data['name'], self._zone_name)
def test_raw_json_is_stored(self): "Check that the raw json is set on the class" genius_zone = GeniusZone(self._device_id, self.raw_json, self.hub) self.assertEqual(genius_zone._raw, self.raw_json)