def test_preprocessor_process(patch, magic, tree, block): patch.many(Preprocessor, ['assignments', 'service', 'flow_statement']) tree.find_data.return_value = [block] result = Preprocessor.process(tree) Preprocessor.assignments.assert_called_with(block) Preprocessor.service.assert_called_with(block) Preprocessor.flow_statement.assert_called_with('elseif_statement', block) assert result == tree
def test_preprocessor_process(patch, magic, tree): patch.many(Preprocessor, ['assignments', 'service']) block = magic() tree.find_data.return_value = [block] result = Preprocessor.process(tree) Preprocessor.assignments.assert_called_with(block) Preprocessor.service.assert_called_with(block) assert result == tree
def test_compiler_compile(patch): patch.object(Preprocessor, 'process') patch.many(Compiler, ['parse_tree', 'compiler']) result = Compiler.compile('tree') Preprocessor.process.assert_called_with('tree') Compiler.compiler().parse_tree.assert_called_with(Preprocessor.process()) lines = Compiler.compiler().lines expected = {'tree': lines.lines, 'version': version, 'services': lines.get_services(), 'functions': lines.functions, 'entrypoint': lines.first(), 'modules': lines.modules} assert result == expected