Пример #1
0
 def test_process_zone_event(self, mock_update):
     """Test the processing of zone events."""
     zone1 = {'number': 1, 'name': 'foo', 'state': True}
     zone2 = {'number': 2, 'name': 'bar', 'state': True}
     zones = {
         1: nx584.NX584ZoneSensor(zone1, 'motion'),
         2: nx584.NX584ZoneSensor(zone2, 'motion'),
     }
     watcher = nx584.NX584Watcher(None, zones)
     watcher._process_zone_event({'zone': 1, 'zone_state': False})
     assert not zone1['state']
     assert 1 == mock_update.call_count
Пример #2
0
 def test_process_zone_event(self, mock_update):
     """Test the processing of zone events."""
     zone1 = {"number": 1, "name": "foo", "state": True}
     zone2 = {"number": 2, "name": "bar", "state": True}
     zones = {
         1: nx584.NX584ZoneSensor(zone1, "motion"),
         2: nx584.NX584ZoneSensor(zone2, "motion"),
     }
     watcher = nx584.NX584Watcher(None, zones)
     watcher._process_zone_event({"zone": 1, "zone_state": False})
     assert not zone1["state"]
     assert mock_update.call_count == 1
Пример #3
0
    def test_sensor_normal(self):
        """Test the sensor."""
        zone = {'number': 1, 'name': 'foo', 'state': True}
        sensor = nx584.NX584ZoneSensor(zone, 'motion')
        assert 'foo' == sensor.name
        assert not sensor.should_poll
        assert sensor.is_on

        zone['state'] = False
        assert not sensor.is_on
Пример #4
0
    def test_sensor_normal(self):
        """Test the sensor."""
        zone = {"number": 1, "name": "foo", "state": True}
        sensor = nx584.NX584ZoneSensor(zone, "motion")
        assert "foo" == sensor.name
        assert not sensor.should_poll
        assert sensor.is_on

        zone["state"] = False
        assert not sensor.is_on
Пример #5
0
def test_nx584_zone_sensor_normal():
    """Test for the NX584 zone sensor."""
    zone = {"number": 1, "name": "foo", "state": True}
    sensor = nx584.NX584ZoneSensor(zone, "motion")
    assert sensor.name == "foo"
    assert not sensor.should_poll
    assert sensor.is_on
    assert sensor.extra_state_attributes["zone_number"] == 1

    zone["state"] = False
    assert not sensor.is_on