Пример #1
0
 def test_get_wl(self, mocked_ssh):
     """Testing wl."""
     mocked_ssh.run_command.return_value = WL_DATA
     scanner = get_scanner(self.hass, VALID_CONFIG_ROUTER_SSH)
     scanner.connection = mocked_ssh
     self.assertEqual(WL_DEVICES, scanner._get_wl())
     mocked_ssh.run_command.return_value = ''
     self.assertEqual({}, scanner._get_wl())
Пример #2
0
 def test_get_wl(self, mocked_ssh):
     """Testing wl."""
     mocked_ssh.run_command.return_value = WL_DATA
     scanner = get_scanner(self.hass, VALID_CONFIG_ROUTER_SSH)
     scanner.connection = mocked_ssh
     self.assertEqual(WL_DEVICES, scanner._get_wl())
     mocked_ssh.run_command.return_value = ''
     self.assertEqual({}, scanner._get_wl())
Пример #3
0
 def test_update_info(self):
     """Test for update info."""
     scanner = get_scanner(self.hass, VALID_CONFIG_ROUTER_SSH)
     scanner.get_asuswrt_data = mock.Mock()
     scanner.get_asuswrt_data.return_value = WAKE_DEVICES
     self.assertTrue(scanner._update_info())
     self.assertTrue(scanner.last_results, WAKE_DEVICES)
     scanner.success_init = False
     self.assertFalse(scanner._update_info())
Пример #4
0
 def test_update_info(self):
     """Test for update info."""
     scanner = get_scanner(self.hass, VALID_CONFIG_ROUTER_SSH)
     scanner.get_asuswrt_data = mock.Mock()
     scanner.get_asuswrt_data.return_value = WAKE_DEVICES
     self.assertTrue(scanner._update_info())
     self.assertTrue(scanner.last_results, WAKE_DEVICES)
     scanner.success_init = False
     self.assertFalse(scanner._update_info())
Пример #5
0
    def test_get_neigh(self, mocked_ssh):
        """Testing neigh."""
        mocked_ssh.run_command.return_value = NEIGH_DATA

        scanner = get_scanner(self.hass, VALID_CONFIG_ROUTER_SSH)
        scanner.connection = mocked_ssh
        self.assertEqual(NEIGH_DEVICES, scanner._get_neigh(ARP_DEVICES.copy()))
        mocked_ssh.run_command.return_value = ''
        self.assertEqual({}, scanner._get_neigh(ARP_DEVICES.copy()))
Пример #6
0
    def test_get_leases(self, mocked_ssh):
        """Testing leases."""
        mocked_ssh.run_command.return_value = LEASES_DATA

        scanner = get_scanner(self.hass, VALID_CONFIG_ROUTER_SSH)
        scanner.connection = mocked_ssh
        self.assertEqual(
            LEASES_DEVICES, scanner._get_leases(NEIGH_DEVICES.copy()))
        mocked_ssh.run_command.return_value = ''
        self.assertEqual({}, scanner._get_leases(NEIGH_DEVICES.copy()))
Пример #7
0
 def test_get_asuswrt_data(self):
     """Test asuswrt data fetch."""
     scanner = get_scanner(self.hass, VALID_CONFIG_ROUTER_SSH)
     scanner._get_wl = mock.Mock()
     scanner._get_arp = mock.Mock()
     scanner._get_neigh = mock.Mock()
     scanner._get_leases = mock.Mock()
     scanner._get_wl.return_value = WL_DEVICES
     scanner._get_arp.return_value = ARP_DEVICES
     scanner._get_neigh.return_value = NEIGH_DEVICES
     scanner._get_leases.return_value = LEASES_DEVICES
     self.assertEqual(WAKE_DEVICES, scanner.get_asuswrt_data())
Пример #8
0
    def test_get_neigh(self, mocked_ssh):
        """Testing neigh."""
        mocked_ssh.run_command.return_value = NEIGH_DATA

        scanner = get_scanner(self.hass, VALID_CONFIG_ROUTER_SSH)
        scanner.connection = mocked_ssh
        self.assertEqual(NEIGH_DEVICES, scanner._get_neigh(ARP_DEVICES.copy()))
        self.assertEqual(NEIGH_DEVICES, scanner._get_neigh({
            'UN:KN:WN:DE:VI:CE': Device('UN:KN:WN:DE:VI:CE', None, None),
        }))
        mocked_ssh.run_command.return_value = ''
        self.assertEqual({}, scanner._get_neigh(ARP_DEVICES.copy()))
Пример #9
0
 def test_get_asuswrt_data(self):
     """Test asuswrt data fetch."""
     scanner = get_scanner(self.hass, VALID_CONFIG_ROUTER_SSH)
     scanner._get_wl = mock.Mock()
     scanner._get_arp = mock.Mock()
     scanner._get_neigh = mock.Mock()
     scanner._get_leases = mock.Mock()
     scanner._get_wl.return_value = WL_DEVICES
     scanner._get_arp.return_value = ARP_DEVICES
     scanner._get_neigh.return_value = NEIGH_DEVICES
     scanner._get_leases.return_value = LEASES_DEVICES
     self.assertEqual(WAKE_DEVICES, scanner.get_asuswrt_data())
Пример #10
0
 def test_scan_devices(self):
     """Test for scan devices."""
     scanner = get_scanner(self.hass, VALID_CONFIG_ROUTER_SSH)
     scanner.last_results = WAKE_DEVICES
     self.assertEqual(list(WAKE_DEVICES), scanner.scan_devices())
Пример #11
0
 def test_get_device_name(self):
     """Test for getting name."""
     scanner = get_scanner(self.hass, VALID_CONFIG_ROUTER_SSH)
     scanner.last_results = WAKE_DEVICES
     self.assertEqual('TV', scanner.get_device_name('01:02:03:04:06:08'))
     self.assertEqual(None, scanner.get_device_name('01:02:03:04:08:08'))
Пример #12
0
 def test_scan_devices(self):
     """Test for scan devices."""
     scanner = get_scanner(self.hass, VALID_CONFIG_ROUTER_SSH)
     scanner.last_results = WAKE_DEVICES
     self.assertEqual(list(WAKE_DEVICES), scanner.scan_devices())
Пример #13
0
 def test_get_device_name(self):
     """Test for getting name."""
     scanner = get_scanner(self.hass, VALID_CONFIG_ROUTER_SSH)
     scanner.last_results = WAKE_DEVICES
     self.assertEqual('TV', scanner.get_device_name('01:02:03:04:06:08'))
     self.assertEqual(None, scanner.get_device_name('01:02:03:04:08:08'))