def test_transformer_when_block(patch, tree): """ Ensures when_block nodes are transformed correctly """ patch.object(Transformer, 'implicit_output') result = Transformer.when_block([tree]) Transformer.implicit_output.assert_called_with(tree) assert result == Tree('when_block', [tree])
def test_transformer_when_block(patch, tree): """ Ensures when_block nodes are transformed correctly """ tree.data = 'when_service' tree.output = None tree.children = [Token('NAME', '.name.')] tree.child_token.return_value = Token('NAME', '.child.', line=42) tree.path.child_token.return_value = Token('NAME', '.path.') result = Transformer.when_block([tree, 'block']) assert result == Tree('concise_when_block', [ Token('NAME', '.child.'), Token('NAME', '.path.'), Tree('when_block', [tree, 'block']) ])
def test_transformer_when_block_no_command(patch, tree): """ Ensures when_block nodes without command are transformed correctly """ patch.object(Transformer, 'argument_shorthand') tree.data = 'when_service' tree.output = None tree.children = [Token('NAME', '.name.')] tree.service_fragment.command = None result = Transformer.when_block([tree, 'block']) assert result == Tree('when_block', [ Tree('service', [ Tree('path', [tree.child_token()]), tree.service_fragment, ]), 'block', ])
def test_transformer_when_block(patch, tree): """ Ensures when_block nodes are transformed correctly """ tree.data = "when_service" tree.output = None tree.children = [Token("NAME", ".name.")] tree.child_token.return_value = Token("NAME", ".child.", line=42) tree.path.child_token.return_value = Token("NAME", ".path.") result = Transformer.when_block([tree, "block"]) assert result == Tree( "concise_when_block", [ Token("NAME", ".child."), Token("NAME", ".path."), Tree("when_block", [tree, "block"]), ], )
def test_transformer_when_block_no_command(patch, tree): """ Ensures when_block nodes without command are transformed correctly """ patch.object(Transformer, "argument_shorthand") tree.data = "when_service" tree.output = None tree.children = [Token("NAME", ".name.")] tree.service_fragment.command = None result = Transformer.when_block([tree, "block"]) assert result == Tree( "when_block", [ Tree( "service", [ Tree("path", [tree.child_token()]), tree.service_fragment, ], ), "block", ], )