Esempio n. 1
0
 def test_device_menu(self, stdout):
     """device_menu: choosing a number returns that Device"""
     choose_num='2'
     with mock.patch('driver_updates._input', return_value=choose_num):
         result = device_menu()
     # if you hit '2' you should get the corresponding device from the list
     self.assertEqual(len(result), 1)
     dev = result[0]
     self.assertEqual(vars(dev), vars(devicelist[int(choose_num)-1]))
     # find the corresponding line on-screen
     screen = [l.strip() for l in stdout.getvalue().splitlines()]
     match = [l for l in screen if l.startswith(choose_num+')')]
     self.assertEqual(len(match), 1)
     line = match.pop(0)
     # the device name (at least) should be on this line
     self.assertIn(os.path.basename(dev.device), line)
Esempio n. 2
0
 def test_device_menu(self, stdout):
     """device_menu: choosing a number returns that Device"""
     choose_num = '2'
     with mock.patch('driver_updates._input', return_value=choose_num):
         result = device_menu()
     # if you hit '2' you should get the corresponding device from the list
     self.assertEqual(len(result), 1)
     dev = result[0]
     self.assertEqual(vars(dev), vars(devicelist[int(choose_num) - 1]))
     # find the corresponding line on-screen
     screen = [l.strip() for l in stdout.getvalue().splitlines()]
     match = [l for l in screen if l.startswith(choose_num + ')')]
     self.assertEqual(len(match), 1)
     line = match.pop(0)
     # the device name (at least) should be on this line
     self.assertIn(os.path.basename(dev.device), line)
Esempio n. 3
0
 def test_device_menu_refresh(self):
     """device_menu: 'r' makes the menu refresh"""
     with mock.patch('driver_updates._input', side_effect=['r','c']):
         device_menu()
     self.assertEqual(self.mocks['get_deviceinfo'].call_count, 2)
Esempio n. 4
0
 def test_device_menu_exit(self):
     """device_menu: 'c' exits the menu"""
     with mock.patch('driver_updates._input', side_effect=['c']):
         dev = device_menu()
     self.assertEqual(dev, [])
     self.assertEqual(self.mocks['get_deviceinfo'].call_count, 1)
Esempio n. 5
0
 def test_device_menu_refresh(self):
     """device_menu: 'r' makes the menu refresh"""
     with mock.patch('driver_updates._input', side_effect=['r', 'c']):
         device_menu()
     self.assertEqual(self.mocks['get_deviceinfo'].call_count, 2)
Esempio n. 6
0
 def test_device_menu_exit(self):
     """device_menu: 'c' exits the menu"""
     with mock.patch('driver_updates._input', side_effect=['c']):
         dev = device_menu()
     self.assertEqual(dev, [])
     self.assertEqual(self.mocks['get_deviceinfo'].call_count, 1)