예제 #1
0
 def test_simple(self):
     driver = Mock()
     primaryDevice = Mock()
     driver.getCommand = MagicMock(
         return_value=PolyTester.config['simple']['commands']['command1'])
     driver.getData = MagicMock(return_value={})
     device = RemoteDevice(None, primaryDevice, None, None, None, "test device",
                           PolyTester.config['simple'], driver)
     device.runCmd({'cmd': 'command1'})
     driver.executeCommand.assert_called_with('command1', None)
예제 #2
0
 def test_prefix(self):
     driver = Mock()
     driver.getData = Mock(return_value={'result': 1})
     primaryDevice = Mock()
     driver.getCommand = MagicMock(return_value=None)
     primaryDevice.connected = True
     device = RemoteDevice(None, primaryDevice, None, None, None, "test device",
                           PolyTester.config['prefix']['commandGroups']['group1'], driver)
     device.runCmd({'cmd': 'command1'})
     driver.executeCommand.assert_called_with('g1_command1', None)
     driver.getData.assert_called_with('g1_command2')
예제 #3
0
 def test_read_only(self):
     driver = Mock()
     primaryDevice = Mock()
     driver.getCommand = MagicMock(
         return_value=PolyTester.config['read_only']['commands']['command3'])
     driver.getData = MagicMock(return_value={})
     device = RemoteDevice(None, primaryDevice, None, None, None, "test device",
                           PolyTester.config['read_only'], driver)
     device.runCmd({'cmd': 'command3'})
     driver.executeCommand.assert_called_with('command3', None)
     self.assertEqual(device.driverSetters['GV0'], 'command3')
예제 #4
0
 def test_read_only_prefix(self):
     driver = Mock()
     primaryDevice = Mock()
     data = PolyTester.config['read_only_prefix']['commandGroups']['group1']
     driver.getCommand = MagicMock(
         return_value=data['commands']['command1'])
     driver.getData = MagicMock(return_value={})
     device = RemoteDevice(None, primaryDevice, None, None, None, "test device",
                           data, driver)
     device.runCmd({'cmd': 'command1'})
     driver.executeCommand.assert_called_with('r1_command1', None)
     self.assertEqual(device.driverSetters['GV0'], 'r1_command1')
예제 #5
0
 def test_skips_bad_input_command(self):
     driver = Mock()
     driver.getData = Mock(return_value={'result': 1})
     driver.hasCommand = Mock(return_value=False)
     primaryDevice = Mock()
     driver.getCommand = MagicMock(return_value=None)
     primaryDevice.connected = True
     device = RemoteDevice(None, primaryDevice, None, None, None, "test device",
                           PolyTester.config['state'], driver)
     device.runCmd({'cmd': 'command1'})
     driver.executeCommand.assert_called_with('command1', None)
     driver.getData.assert_not_called()