Ejemplo n.º 1
0
 def test_send_confirmation(self):
     device = Device('key', {'confirmation': 'tg'}, {'confirmations': {
         'tg': {'service': 'disabled'},
     }})
     with patch.object(DisabledConfirmation, 'send') as send_mock:
         device.execute()
         send_mock.assert_called_once()
Ejemplo n.º 2
0
 def test_no_execute(self):
     device = Device('key')
     with patch.object(logger, 'warning') as warning_mock:
         device.execute()
         warning_mock.assert_called_once()
     with patch.object(Device, 'send_confirmation') as send_confirmation_mock:
         device.execute()
         send_confirmation_mock.assert_called_once()
Ejemplo n.º 3
0
 def test_execute_error(self):
     device = Device(
         'key', {
             'cmd': "command",
             'user': "******",
             'cwd': "/dir",
             'name': "Command Name",
         }, {'confirmations': {'tg': {'service': 'disabled'}}}
     )
     with patch.object(Device, 'send_confirmation') as send_confirmation_mock:
         self.execute_mock.stop()
         execute_mock = patch.object(ExecuteCmd, 'execute', side_effect=Exception())
         execute_mock.start()
         with self.assertRaises(Exception):
             device.execute()
         send_confirmation_mock.assert_called_once()
         execute_mock.stop()
         self.execute_mock.start()