def test_compiler_arguments(patch, compiler, lines, tree): patch.object(Objects, 'arguments') lines.last.return_value = '1' lines.lines = {'1': {'method': 'execute', 'args': ['args']}} compiler.arguments(tree, '0') Objects.arguments.assert_called_with(tree) assert lines.lines['1']['args'] == ['args'] + Objects.arguments()
def test_objects_arguments(patch, tree): patch.object(Objects, 'argument') tree.find_data.return_value = ['argument'] result = Objects.arguments(tree) tree.find_data.assert_called_with('arguments') Objects.argument.assert_called_with('argument') assert result == [Objects.argument()]
def test_compiler_arguments(patch, compiler, tree): patch.object(Compiler, 'last_line', return_value='1') patch.object(Objects, 'arguments') compiler.lines = {'1': {'method': 'execute', 'args': ['args']}} compiler.arguments(tree) Objects.arguments.assert_called_with(tree) assert compiler.lines['1']['args'] == ['args'] + Objects.arguments()
def test_objects_mutation_arguments(patch, magic): """ Ensures that mutations objects with arguments are compiled correctly. """ patch.object(Objects, 'arguments') tree = magic() result = Objects.mutation(tree) Objects.arguments.assert_called_with(tree) assert result['arguments'] == Objects.arguments()
def test_compiler_service_command(patch, compiler, lines, tree): patch.object(Objects, 'arguments') patch.object(Compiler, 'output') compiler.service(tree, None, 'parent') line = tree.line() service = tree.path.extract_path() command = tree.service_fragment.command.child() lines.set_scope.assert_called_with(line, 'parent', Compiler.output()) lines.execute.assert_called_with(line, service, command, Objects.arguments(), Compiler.output(), None, 'parent')
def test_compiler_service_parent(patch, compiler, tree): patch.object(Objects, 'arguments') patch.many(Compiler, ['add_line', 'output']) tree.node.return_value = None compiler.service(tree, parent='1') line = tree.line() service = tree.child().child().value compiler.add_line.assert_called_with('execute', line, service=service, command=tree.node(), args=Objects.arguments(), output=Compiler.output(), parent='1')
def test_compiler_service_nested_block(patch, magic, compiler, lines, tree): patch.object(Objects, 'arguments') patch.object(Compiler, 'output') tree.node.return_value = None nested_block = magic() compiler.service(tree, nested_block, 'parent') line = tree.line() service = tree.path.extract_path() command = tree.service_fragment.command.child() lines.execute.assert_called_with(line, service, command, Objects.arguments(), Compiler.output(), nested_block.line(), 'parent')
def test_objects_method(patch, tree): patch.object(Objects, 'arguments') result = Objects.method(tree) Objects.arguments.assert_called_with(tree.node()) expected = { '$OBJECT': 'method', 'method': 'execute', 'service': tree.child().child().value, 'command': tree.node().child().value, 'output': None, 'args': Objects.arguments() } assert result == expected
def test_compiler_service(patch, compiler, lines, tree): """ Ensures that service trees can be compiled """ patch.object(Objects, 'arguments') patch.object(Compiler, 'output') tree.node.return_value = None compiler.service(tree, None, 'parent') line = tree.line() service = tree.path.extract_path() command = tree.service_fragment.command.child() Objects.arguments.assert_called_with(tree.service_fragment) Compiler.output.assert_called_with(tree.service_fragment.output) lines.execute.assert_called_with(line, service, command, Objects.arguments(), Compiler.output(), None, 'parent')
def test_compiler_service(patch, compiler, tree): """ Ensures that service trees can be compiled """ patch.object(Objects, 'arguments') patch.many(Compiler, ['add_line', 'output']) tree.node.return_value = None compiler.service(tree) line = tree.line() service = tree.child().child().value Objects.arguments.assert_called_with(tree.node()) Compiler.output.assert_called_with(tree.node()) compiler.add_line.assert_called_with('execute', line, service=service, command=tree.node(), parent=None, args=Objects.arguments(), output=Compiler.output())