def test_compiler_mutation_block_nested(patch, compiler, lines, tree): patch.many(Objects, ['expression', 'mutation_fragment']) patch.object(JSONCompiler, 'chained_mutations', return_value=['chained']) tree.path = None compiler.mutation_block(tree, None) JSONCompiler.chained_mutations.assert_called_with(tree.nested_block) args = [Objects.expression(), Objects.mutation_fragment(), 'chained', 'chained'] kwargs = {'args': args, 'parent': None} lines.append.assert_called_with('mutation', tree.position(), **kwargs)
def test_compiler_mutation_block_nested(patch, compiler, lines, tree): patch.many(Objects, ["expression", "mutation_fragment"]) patch.object(JSONCompiler, "chained_mutations", return_value=["chained"]) tree.path = None compiler.mutation_block(tree, None) JSONCompiler.chained_mutations.assert_called_with(tree.nested_block) args = [ Objects.expression(), Objects.mutation_fragment(), "chained", "chained", ] kwargs = {"args": args, "parent": None} lines.append.assert_called_with("mutation", tree.position(), **kwargs)
def test_compiler_assignment_unary(patch, compiler, lines, tree): """ Ensures a line like "x = value" is compiled correctly """ patch.many(Objects, ['names', 'entity', 'expression']) af = tree.assignment_fragment.base_expression af.service = None af.mutation = None lines.lines = {lines.last(): {'method': None}} compiler.assignment(tree, '1') Objects.names.assert_called_with(tree.path) Objects.expression.assert_called_with(af.expression) kwargs = {'args': [Objects.expression()], 'parent': '1'} lines.append.assert_called_with('expression', tree.position(), **kwargs) lines.set_name.assert_called_with(Objects.names())
def test_compiler_assignment_unary(patch, compiler, lines, tree): """ Ensures a line like "x = value" is compiled correctly """ patch.many(Objects, ["names", "entity", "expression"]) af = tree.assignment_fragment.base_expression af.service = None af.mutation = None lines.lines = {lines.last(): {"method": None}} compiler.assignment(tree, "1") Objects.names.assert_called_with(tree.path) Objects.expression.assert_called_with(af.expression) kwargs = {"args": [Objects.expression()], "parent": "1"} lines.append.assert_called_with("expression", tree.position(), **kwargs) lines.set_name.assert_called_with(Objects.names())
def test_compiler_extract_values_expression(patch, tree): patch.object(Objects, 'expression') tree.expression.mutation = None result = JSONCompiler(story=None).extract_values(tree) Objects.expression.assert_called_with(tree.expression) assert result == [Objects.expression()]