Beispiel #1
0
    def test_generate_command(self, cmd):
        assert not hasattr(cmd, '_command')
        command(cmd)

        assert hasattr(cmd, '_command')
        assert cmd._command.name == '_cmd'
        assert cmd._command.description == 'Docstring'
        assert len(cmd._command.parameters) == 1
Beispiel #2
0
    def test_generate_command_python2(self, func_mock):
        # Apparently Python 2 adds some extra stuff
        func_mock.func_name = 'func_name'
        func_mock.func_doc = 'func_doc'

        command(func_mock)
        assert 'func_name' == func_mock._command.name
        assert 'func_doc' == func_mock._command.description
Beispiel #3
0
    def test_generate_command(self, cmd):
        assert not hasattr(cmd, "_command")
        command(cmd)

        assert hasattr(cmd, "_command")
        assert cmd._command.name == "_cmd"
        assert cmd._command.description == "Docstring"
        assert len(cmd._command.parameters) == 1
Beispiel #4
0
    def test_update(self, cmd):
        command(cmd, command_type="ACTION", description="desc1", output_type="XML")
        command(cmd, command_type="INFO", description="desc2", output_type="JSON")

        assert cmd._command.name == "_cmd"
        assert cmd._command.command_type == "INFO"
        assert cmd._command.description == "desc2"
        assert cmd._command.output_type == "JSON"
Beispiel #5
0
    def test_multiple(self, cmd):
        """Subsequent decorators should completely overwrite previous ones"""
        command(cmd,
                command_type="ACTION",
                description="desc1",
                output_type="JSON")
        command(cmd, command_type="INFO", description="desc2")

        assert cmd._command.command_type == "INFO"
        assert cmd._command.description == "desc2"
        assert cmd._command.output_type == "STRING"  # This is the default
Beispiel #6
0
    def test_update(self, cmd):
        command(cmd,
                command_type='ACTION',
                description='desc1',
                output_type='XML')
        command(cmd,
                command_type='INFO',
                description='desc2',
                output_type='JSON')

        assert cmd._command.name == '_cmd'
        assert cmd._command.command_type == 'INFO'
        assert cmd._command.description == 'desc2'
        assert cmd._command.output_type == 'JSON'
Beispiel #7
0
 def test_cmd_parameter(self, cmd):
     cmd = command(cmd)
     cmd = parameter(cmd, key="foo")
     assert _parse_method(cmd) is not None
Beispiel #8
0
 def test_only_command(self, cmd):
     cmd = command(cmd)
     assert _parse_method(cmd) is not None
Beispiel #9
0
 def test_generate_command_python3(self, func_mock):
     command(func_mock)
     assert '__name__' == func_mock._command.name
     assert '__doc__' == func_mock._command.description
Beispiel #10
0
    def test_command_wrapper(self, cmd, wrap_functions):
        test_mock = Mock()
        wrapped = command(cmd)

        assert wrapped(self, test_mock) == test_mock
Beispiel #11
0
    def test_command_function(self, cmd, wrap):
        brewtils.decorators._wrap_functions = wrap
        command(cmd)

        assert cmd(self, 'input') == 'input'