コード例 #1
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")
コード例 #2
0
ファイル: test_nx584.py プロジェクト: 12-hak/hak-assistant
 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)
コード例 #3
0
ファイル: test_nx584.py プロジェクト: x86Labs/home-assistant
 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')
コード例 #4
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)
コード例 #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")
コード例 #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')
コード例 #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')
コード例 #8
0
ファイル: test_nx584.py プロジェクト: 12-hak/hak-assistant
 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)
コード例 #9
0
ファイル: test_nx584.py プロジェクト: krzynio/home-assistant
 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')
     )
コード例 #10
0
ファイル: test_nx584.py プロジェクト: x86Labs/home-assistant
 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)
コード例 #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
コード例 #12
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_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)
コード例 #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)
コード例 #14
0
ファイル: test_nx584.py プロジェクト: x86Labs/home-assistant
 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)
コード例 #15
0
ファイル: test_nx584.py プロジェクト: x86Labs/home-assistant
 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)
コード例 #16
0
ファイル: test_nx584.py プロジェクト: jaharkes/home-assistant
 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)
コード例 #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