Esempio n. 1
0
def test_nx584_sensor_setup_defaults(mock_nx, mock_watcher, hass, fake_zones):
    """Test the setup with no configuration."""
    add_entities = mock.MagicMock()
    config = DEFAULT_CONFIG
    nx584.setup_platform(hass, config, add_entities)
    mock_nx.assert_has_calls([mock.call(zone, "opening") for zone in fake_zones])
    assert add_entities.called
    assert nx584_client.Client.call_count == 1
    assert nx584_client.Client.call_args == mock.call("http://localhost:5007")
Esempio n. 2
0
def test_nx584_sensor_setup_no_zones(hass):
    """Test the setup with no zones."""
    nx584_client.Client.return_value.list_zones.return_value = []
    add_entities = mock.MagicMock()
    nx584.setup_platform(
        hass,
        DEFAULT_CONFIG,
        add_entities,
    )
    assert not add_entities.called
Esempio n. 3
0
def test_nx584_sensor_setup_full_config(mock_nx, mock_watcher, hass, fake_zones):
    """Test the setup with full configuration."""
    config = {
        "host": "foo",
        "port": 123,
        "exclude_zones": [2],
        "zone_types": {3: "motion"},
    }
    add_entities = mock.MagicMock()
    nx584.setup_platform(hass, config, add_entities)
    mock_nx.assert_has_calls(
        [
            mock.call(fake_zones[0], "opening"),
            mock.call(fake_zones[2], "motion"),
        ]
    )
    assert add_entities.called
    assert nx584_client.Client.call_count == 1
    assert nx584_client.Client.call_args == mock.call("http://foo:123")
    assert mock_watcher.called
 def test_setup_defaults(self, mock_nx, mock_watcher):
     """Test the setup with no configuration."""
     add_entities = mock.MagicMock()
     config = {
         'host': nx584.DEFAULT_HOST,
         'port': nx584.DEFAULT_PORT,
         'exclude_zones': [],
         'zone_types': {},
     }
     assert nx584.setup_platform(self.hass, config, add_entities)
     mock_nx.assert_has_calls(
         [mock.call(zone, 'opening') for zone in self.fake_zones])
     assert add_entities.called
     assert nx584_client.Client.call_count == 1
     assert nx584_client.Client.call_args == \
         mock.call('http://localhost:5007')
 def test_setup_defaults(self, mock_nx, mock_watcher):
     """Test the setup with no configuration."""
     add_entities = mock.MagicMock()
     config = {
         'host': nx584.DEFAULT_HOST,
         'port': nx584.DEFAULT_PORT,
         'exclude_zones': [],
         'zone_types': {},
         }
     assert nx584.setup_platform(self.hass, config, add_entities)
     mock_nx.assert_has_calls(
          [mock.call(zone, 'opening') for zone in self.fake_zones])
     assert add_entities.called
     assert nx584_client.Client.call_count == 1
     assert nx584_client.Client.call_args == \
         mock.call('http://localhost:5007')
 def test_setup_full_config(self, mock_nx, mock_watcher):
     """Test the setup with full configuration."""
     config = {
         'host': 'foo',
         'port': 123,
         'exclude_zones': [2],
         'zone_types': {3: 'motion'},
         }
     add_entities = mock.MagicMock()
     assert nx584.setup_platform(self.hass, config, add_entities)
     mock_nx.assert_has_calls([
         mock.call(self.fake_zones[0], 'opening'),
         mock.call(self.fake_zones[2], 'motion'),
         ])
     assert add_entities.called
     assert nx584_client.Client.call_count == 1
     assert nx584_client.Client.call_args == mock.call('http://foo:123')
     assert mock_watcher.called
 def test_setup_full_config(self, mock_nx, mock_watcher):
     """Test the setup with full configuration."""
     config = {
         'host': 'foo',
         'port': 123,
         'exclude_zones': [2],
         'zone_types': {
             3: 'motion'
         },
     }
     add_entities = mock.MagicMock()
     assert nx584.setup_platform(self.hass, config, add_entities)
     mock_nx.assert_has_calls([
         mock.call(self.fake_zones[0], 'opening'),
         mock.call(self.fake_zones[2], 'motion'),
     ])
     assert add_entities.called
     assert nx584_client.Client.call_count == 1
     assert nx584_client.Client.call_args == mock.call('http://foo:123')
     assert mock_watcher.called
 def test_setup_no_zones(self):
     """Test the setup with no zones."""
     nx584_client.Client.return_value.list_zones.return_value = []
     add_entities = mock.MagicMock()
     assert nx584.setup_platform(self.hass, {}, add_entities)
     assert not add_entities.called
 def test_setup_no_zones(self):
     """Test the setup with no zones."""
     nx584_client.Client.return_value.list_zones.return_value = []
     add_entities = mock.MagicMock()
     assert nx584.setup_platform(self.hass, {}, add_entities)
     assert not add_entities.called