def test_compiler_when_condensed(patch, compiler, lines, tree, magic): patch.object(JSONCompiler, 'service') patch.object(JSONCompiler, 'find_parent_with_output') # manual patching for staticmethod orig_method = Objects.name_to_path Objects.name_to_path = magic() sf = tree.service.service_fragment tree.service.path = '.path.' sf.command = None lines.lines = {'1': {}} lines.last.return_value = lines.lines['1'] compiler.when(tree, 'nested_block', '1') JSONCompiler.service.assert_called_with(tree.service, 'nested_block', '1') assert lines.lines['1']['method'] == 'when' assert sf.command == '.path.' JSONCompiler.find_parent_with_output.assert_called_with(tree, '1') output_name = compiler.find_parent_with_output()[0] Objects.name_to_path.assert_called_with(output_name) assert tree.service.path == Objects.name_to_path() Objects.name_to_path = orig_method
def test_compiler_when_condensed(patch, compiler, lines, tree, magic): patch.object(JSONCompiler, "service") patch.object(JSONCompiler, "find_parent_with_output") # manual patching for staticmethod orig_method = Objects.name_to_path Objects.name_to_path = magic() sf = tree.service.service_fragment tree.service.path = ".path." sf.command = None lines.lines = {"1": {}} lines.last.return_value = lines.lines["1"] compiler.when(tree, "nested_block", "1") JSONCompiler.service.assert_called_with(tree.service, "nested_block", "1") assert lines.lines["1"]["method"] == "when" assert sf.command == ".path." JSONCompiler.find_parent_with_output.assert_called_with(tree, "1") output_name = compiler.find_parent_with_output()[0] Objects.name_to_path.assert_called_with(output_name) assert tree.service.path == Objects.name_to_path() Objects.name_to_path = orig_method