Example #1
0
class TestCommandConfigUpdate(UnitTestCase):
    def setUp(self):
        super(TestCommandConfigUpdate, self).setUp()
        self.job = Job(slug='cthulhubot-sleep').get_domain_object()

    def test_bad_command_raises_error(self):
        self.assert_raises(ValueError, self.job.update_command_config, 5, {})

    def test_mismatched_command_name(self):
        self.assert_raises(ValueError, self.job.update_command_config, 0, {'command' : 'blahblahblah', 'parameters' : {'time' : 5}})

    def test_config_updated(self):
        self.job.update_command_config(0, {'command' : 'cthulhubot-sleep', 'parameters' : {'time' : 5}})
        self.assert_equals(5, self.job.get_parameter_dict(0, 'time'))
Example #2
0
class TestSlotReplacement(UnitTestCase):

    def setUp(self):
        super(TestSlotReplacement, self).setUp()
        self.job = Job(slug='cthulhubot-test-output-job').get_domain_object()

    def test_slot_command_propagated_according_to_config(self):
        config = {
            'command' : 'cthulhubot-test-helper-echo',
            'parameters' : {}
        }
        self.job.update_command_config(0, config)

        self.assert_equals(config['command'], self.job.get_configuration_parameters()[0]['command'])

    def test_update_with_command_from_other_slot_prohibited(self):
        self.assert_raises(ValueError, self.job.update_command_config, 0, {'command' : 'cthulhubot-sleep', 'parameters' : {}})

    def test_attempt_to_work_with_unconfigured_slot_raises_error(self):
        self.assert_raises(UnconfiguredCommandError, self.job.get_commands)