Exemplo n.º 1
0
def test_preprocessor_assignments_no_expression(patch, magic, tree):
    patch.object(Preprocessor, 'assignment_expression')
    assignment = magic()
    assignment.assignment_fragment.service = None
    assignment.assignment_fragment.values.inline_expression = None
    tree.find_data.return_value = [assignment]
    Preprocessor.assignments(tree)
    assert Preprocessor.assignment_expression.call_count == 0
Exemplo n.º 2
0
def test_preprocessor_assignments_no_expression(patch, magic, tree):
    patch.object(Preprocessor, 'assignment_expression')
    assignment = magic()
    assignment.assignment_fragment.service = None
    fragment = assignment.assignment_fragment
    factor = fragment.expression.multiplication.exponential.factor
    factor.entity.path.inline_expression = None
    tree.find_data.return_value = [assignment]
    Preprocessor.assignments(tree)
    assert Preprocessor.assignment_expression.call_count == 0
Exemplo n.º 3
0
def test_preprocessor_assignments(patch, magic, tree):
    """
    Ensures Preprocessor.assignments can process lines like
    a = alpine echo text:(random value)
    """
    patch.object(Preprocessor, 'service_arguments')
    assignment = magic()
    tree.find_data.return_value = [assignment]
    Preprocessor.assignments(tree)
    args = (tree, assignment.assignment_fragment.service)
    Preprocessor.service_arguments.assert_called_with(*args)
Exemplo n.º 4
0
def test_preprocessor_assignments_to_expression(patch, magic, tree):
    """
    Ensures Preprocessor.assignments can processs lines like
    a = (alpine echo message:'text')
    """
    patch.object(Preprocessor, 'assignment_expression')
    assignment = magic()
    assignment.assignment_fragment.service = None
    tree.find_data.return_value = [assignment]
    Preprocessor.assignments(tree)
    args = (tree, assignment.assignment_fragment.values)
    Preprocessor.assignment_expression.assert_called_with(*args)
Exemplo n.º 5
0
def test_preprocessor_assignments_to_expression(patch, magic, tree):
    """
    Ensures Preprocessor.assignments can process lines like
    a = (alpine echo message:'text')
    """
    patch.object(Preprocessor, 'assignment_expression')
    assignment = magic()
    assignment.assignment_fragment.service = None
    tree.find_data.return_value = [assignment]
    Preprocessor.assignments(tree)
    fragment = assignment.assignment_fragment
    factor = fragment.expression.multiplication.exponential.factor
    args = (tree, factor.entity.path)
    Preprocessor.assignment_expression.assert_called_with(*args)