Ejemplo n.º 1
0
def test_compiler_arguments(patch, compiler, lines, tree):
    patch.object(Objects, 'arguments')
    lines.lines = {'1': {'method': 'execute', 'args': ['args']}}
    lines.last.return_value = lines.lines['1']
    compiler.arguments(tree, '0')
    Objects.arguments.assert_called_with(tree)
    assert lines.lines['1']['args'] == ['args'] + Objects.arguments()
Ejemplo n.º 2
0
def test_compiler_arguments(patch, compiler, lines, tree):
    patch.object(Objects, "arguments")
    lines.lines = {"1": {"method": "execute", "args": ["args"]}}
    lines.last.return_value = lines.lines["1"]
    compiler.arguments(tree, "0")
    Objects.arguments.assert_called_with(tree)
    assert lines.lines["1"]["args"] == ["args"] + Objects.arguments()
Ejemplo n.º 3
0
def test_compiler_service_command(patch, compiler, lines, tree):
    patch.object(Objects, 'arguments')
    patch.object(JSONCompiler, 'output')
    tree.data = 'service'
    compiler.service(tree, None, 'parent')
    position = tree.position()
    service = tree.path.extract_path()
    command = tree.service_fragment.command.child()
    lines.execute.assert_called_with(position, service, command,
                                     Objects.arguments(), compiler.output(),
                                     None, 'parent')
Ejemplo n.º 4
0
def test_compiler_call_expression(patch, compiler, lines, tree):
    """
    Ensures that function call expression can be compiled
    """
    patch.many(Objects, ['arguments', 'names'])
    Objects.names.return_values = ['.path.']
    compiler.call_expression(tree, 'parent')
    Objects.arguments.assert_called_with(tree)
    lines.append.assert_called_with('call', tree.position(),
                                    function=tree.path.extract_path(),
                                    args=Objects.arguments(), parent='parent',
                                    output=None)
Ejemplo n.º 5
0
def test_compiler_service_nested_block(patch, magic, compiler, lines, tree):
    patch.object(Objects, 'arguments')
    patch.object(JSONCompiler, 'output')
    tree.node.return_value = None
    nested_block = magic()
    tree.data = 'service'
    compiler.service(tree, nested_block, 'parent')
    position = tree.position()
    service = tree.path.extract_path()
    command = tree.service_fragment.command.child()
    lines.execute.assert_called_with(position, service, command,
                                     Objects.arguments(), compiler.output(),
                                     nested_block.line(), 'parent')
Ejemplo n.º 6
0
def test_compiler_call_expression(patch, compiler, lines, tree):
    """
    Ensures that function call expression can be compiled
    """
    patch.many(Objects, ["arguments", "names"])
    Objects.names.return_values = [".path."]
    compiler.call_expression(tree, "parent")
    Objects.arguments.assert_called_with(tree)
    lines.append.assert_called_with(
        "call",
        tree.position(),
        function=tree.path.extract_path(),
        args=Objects.arguments(),
        parent="parent",
        output=None,
    )
Ejemplo n.º 7
0
def test_compiler_service(patch, compiler, lines, tree):
    """
    Ensures that service trees can be compiled
    """
    patch.object(Objects, 'arguments')
    patch.object(JSONCompiler, 'output')
    tree.node.return_value = None
    tree.data = 'service'
    compiler.service(tree, None, 'parent')
    position = tree.position()
    service = tree.path.extract_path()
    command = tree.service_fragment.command.child()
    Objects.arguments.assert_called_with(tree.service_fragment)
    JSONCompiler.output.assert_called_with(tree.service_fragment.output)
    lines.execute.assert_called_with(position, service, command,
                                     Objects.arguments(), compiler.output(),
                                     None, 'parent')