def test_setup_no_config(self, mock_nx, mock_watcher):
     add_devices = mock.MagicMock()
     hass = mock.MagicMock()
     self.assertTrue(nx584.setup_platform(hass, {}, add_devices))
     mock_nx.assert_has_calls([mock.call(zone, "opening") for zone in self.fake_zones])
     self.assertTrue(add_devices.called)
     nx584_client.Client.assert_called_once_with("http://localhost:5007")
Example #2
0
 def test_setup_no_zones(self):
     """Test the setup with no zones."""
     nx584_client.Client.return_value.list_zones.return_value = []
     hass = add_devices = mock.MagicMock()
     self.assertTrue(nx584.setup_platform(hass, {},
                                          add_devices))
     self.assertFalse(add_devices.called)
Example #3
0
 def test_setup_no_config(self, mock_nx, mock_watcher):
     add_devices = mock.MagicMock()
     hass = mock.MagicMock()
     self.assertTrue(nx584.setup_platform(hass, {}, add_devices))
     mock_nx.assert_has_calls(
         [mock.call(zone, 'opening') for zone in self.fake_zones])
     self.assertTrue(add_devices.called)
     nx584_client.Client.assert_called_once_with('http://localhost:5007')
 def test_setup_full_config(self, mock_nx, mock_watcher):
     config = {"host": "foo:123", "exclude_zones": [2], "zone_types": {3: "motion"}}
     add_devices = mock.MagicMock()
     hass = mock.MagicMock()
     self.assertTrue(nx584.setup_platform(hass, config, add_devices))
     mock_nx.assert_has_calls([mock.call(self.fake_zones[0], "opening"), mock.call(self.fake_zones[2], "motion")])
     self.assertTrue(add_devices.called)
     nx584_client.Client.assert_called_once_with("http://foo:123")
     self.assertTrue(mock_watcher.called)
Example #5
0
 def test_setup_defaults(self, mock_nx, mock_watcher):
     """Test the setup with no configuration."""
     add_devices = mock.MagicMock()
     hass = mock.MagicMock()
     config = {"host": nx584.DEFAULT_HOST, "port": nx584.DEFAULT_PORT, "exclude_zones": [], "zone_types": {}}
     self.assertTrue(nx584.setup_platform(hass, config, add_devices))
     mock_nx.assert_has_calls([mock.call(zone, "opening") for zone in self.fake_zones])
     self.assertTrue(add_devices.called)
     nx584_client.Client.assert_called_once_with("http://localhost:5007")
Example #6
0
 def test_setup_defaults(self, mock_nx, mock_watcher):
     """Test the setup with no configuration."""
     add_devices = mock.MagicMock()
     hass = mock.MagicMock()
     config = {
         'host': nx584.DEFAULT_HOST,
         'port': nx584.DEFAULT_PORT,
         'exclude_zones': [],
         'zone_types': {},
     }
     self.assertTrue(nx584.setup_platform(hass, config, add_devices))
     mock_nx.assert_has_calls(
         [mock.call(zone, 'opening') for zone in self.fake_zones])
     self.assertTrue(add_devices.called)
     nx584_client.Client.assert_called_once_with('http://localhost:5007')
Example #7
0
 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')
Example #8
0
 def test_setup_full_config(self, mock_nx, mock_watcher):
     """Test the setup with full configuration."""
     config = {
         'host': 'foo:123',
         'exclude_zones': [2],
         'zone_types': {3: 'motion'},
         }
     add_devices = mock.MagicMock()
     hass = mock.MagicMock()
     self.assertTrue(nx584.setup_platform(hass, config, add_devices))
     mock_nx.assert_has_calls([
         mock.call(self.fake_zones[0], 'opening'),
         mock.call(self.fake_zones[2], 'motion'),
         ])
     self.assertTrue(add_devices.called)
     nx584_client.Client.assert_called_once_with('http://foo:123')
     self.assertTrue(mock_watcher.called)
Example #9
0
 def test_setup_defaults(self, mock_nx, mock_watcher):
     """Test the setup with no configuration."""
     add_devices = mock.MagicMock()
     hass = mock.MagicMock()
     config = {
         'host': nx584.DEFAULT_HOST,
         'port': nx584.DEFAULT_PORT,
         'exclude_zones': [],
         'zone_types': {},
         }
     self.assertTrue(nx584.setup_platform(hass, config, add_devices))
     mock_nx.assert_has_calls(
          [mock.call(zone, 'opening') for zone in self.fake_zones])
     self.assertTrue(add_devices.called)
     self.assertEqual(nx584_client.Client.call_count, 1)
     self.assertEqual(
         nx584_client.Client.call_args, mock.call('http://localhost:5007')
     )
Example #10
0
 def test_setup_full_config(self, mock_nx, mock_watcher):
     config = {
         'host': 'foo:123',
         'exclude_zones': [2],
         'zone_types': {
             3: 'motion'
         },
     }
     add_devices = mock.MagicMock()
     hass = mock.MagicMock()
     self.assertTrue(nx584.setup_platform(hass, config, add_devices))
     mock_nx.assert_has_calls([
         mock.call(self.fake_zones[0], 'opening'),
         mock.call(self.fake_zones[2], 'motion'),
     ])
     self.assertTrue(add_devices.called)
     nx584_client.Client.assert_called_once_with('http://foo:123')
     self.assertTrue(mock_watcher.called)
Example #11
0
 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_devices = mock.MagicMock()
     hass = mock.MagicMock()
     self.assertTrue(nx584.setup_platform(hass, config, add_devices))
     mock_nx.assert_has_calls([
         mock.call(self.fake_zones[0], 'opening'),
         mock.call(self.fake_zones[2], 'motion'),
         ])
     self.assertTrue(add_devices.called)
     self.assertEqual(nx584_client.Client.call_count, 1)
     self.assertEqual(
         nx584_client.Client.call_args, mock.call('http://foo:123')
     )
     self.assertTrue(mock_watcher.called)
Example #13
0
 def _test_assert_graceful_fail(self, config):
     hass = add_devices = mock.MagicMock()
     self.assertFalse(nx584.setup_platform(hass, config, add_devices))
     self.assertFalse(add_devices.called)
Example #14
0
 def _test_assert_graceful_fail(self, config):
     hass = add_devices = mock.MagicMock()
     self.assertFalse(nx584.setup_platform(hass, config, add_devices))
     self.assertFalse(add_devices.called)
Example #15
0
 def test_setup_no_zones(self):
     nx584_client.Client.return_value.list_zones.return_value = []
     hass = add_devices = mock.MagicMock()
     self.assertTrue(nx584.setup_platform(hass, {}, add_devices))
     self.assertFalse(add_devices.called)
Example #16
0
 def test_setup_no_zones(self):
     """Test the setup with no zones."""
     nx584_client.Client.return_value.list_zones.return_value = []
     add_devices = mock.MagicMock()
     self.assertTrue(nx584.setup_platform(self.hass, {}, add_devices))
     self.assertFalse(add_devices.called)
Example #17
0
 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