예제 #1
0
    def test_help(self):
        message = vexmessage.Message('target', 'source', 'CMD', command='help')
        self.command_manager.parse_commands(message)
        response_sent = self.command_manager._messaging.response[1]
        self.assertIn('response', response_sent)
        message = vexmessage.Message('target',
                                     'source',
                                     'CMD',
                                     command='help commands')

        self.command_manager.parse_commands(message)
        response_sent = self.command_manager._messaging.response[1]['response']
        self.assertIn('help', response_sent)
        self.assertIn('commands', response_sent)
예제 #2
0
    def test_running(self):

        self.subprocess_manager._subprocess['test'] = MockProcess()
        message = vexmessage.Message('tgt', 'source', 'CMD', command='running')
        self.command_manager.parse_commands(message)
        response = self.command_manager._messaging.response[1]['response']
        self.assertIn('test', response)
예제 #3
0
    def test_terminate(self):
        # TODO: finish
        message = vexmessage.Message('target',
                                     'source',
                                     'CMD',
                                     command='terminate')

        self.command_manager.parse_commands(message)
예제 #4
0
    def test_help_specific(self):
        message = vexmessage.Message('target',
                                     'source',
                                     'CMD',
                                     command='help',
                                     args=['commands'])

        self.command_manager.parse_commands(message)
        response = self.command_manager._messaging.response
        self.assertIsNotNone(response)
예제 #5
0
    def test_subprocesses(self):
        self.subprocess_manager.register('test', object())
        message = vexmessage.Message('tgt',
                                     'source',
                                     'CMD',
                                     command='subprocesses')

        self.command_manager.parse_commands(message)
        response = self.command_manager._messaging.response[1]['response']
        self.assertIn('test', response)
예제 #6
0
    def test_kill(self):
        mock = MockProcess()
        self.subprocess_manager._subprocess['test'] = mock
        message = vexmessage.Message('target',
                                     'source',
                                     'CMD',
                                     command='kill test')

        self.command_manager.parse_commands(message)
        self.assertTrue(mock.killed)
예제 #7
0
    def test_commands(self):
        message = vexmessage.Message('target',
                                     'source',
                                     'CMD',
                                     command='commands')

        self.command_manager.parse_commands(message)
        response_sent = self.command_manager._messaging.response
        answer = response_sent[1]['response']
        self.assertIn('commands', answer)
        self.assertIn('help', answer)
예제 #8
0
    def test_killall(self):
        def _mock_kill(*args, **kwargs):
            # due to scope issues, it's easiest to just tack on to the original
            # message to show that it was called correctly
            args[0].contents['killed'] = True

        self.subprocess_manager.killall = _mock_kill
        self.command_manager._commands['killall'] = _mock_kill

        message = vexmessage.Message('target',
                                     'source',
                                     'CMD',
                                     command='killall')

        self.command_manager.parse_commands(message)
        self.assertTrue(message.contents.get('killed'))
예제 #9
0
    def test_settings(self):
        message = vexmessage.Message('target',
                                     'source',
                                     'CMD',
                                     command='subprocess',
                                     args='settings test',
                                     parsed_args=[
                                         'test',
                                     ])

        self.subprocess_manager.update_settings('test',
                                                {'value': 'test_value'})

        self.command_manager.parse_commands(message)
        response = self.messaging.response[1]['response']
        self.assertIn('value', response)
예제 #10
0
 def test_restart(self):
     # TODO: finish
     message = vexmessage.Message('tgt', 'source', 'CMD', command='restart')
     self.command_manager.parse_commands(message)
예제 #11
0
 def test_alive(self):
     self.subprocess_manager.register('test2', object())
     message = vexmessage.Message('tgt', 'source', 'CMD', command='alive')
     self.command_manager.parse_commands(message)
     commands = self.messaging.commands
     self.assertEqual(commands[1].get('command'), 'alive')