コード例 #1
0
def test_replace_variable_values_no_values():
    test_content = ('<check_type:"Unix">\n'
                    '<custom_item>\n'
                    '  description: "Test value one"\n'
                    '  info : "Test @VAR_ONE@ variable"\n'
                    '</custom_item>\n'
                    '</check_type>')
    assert replace_variable_values(test_content, {}) == test_content
コード例 #2
0
def test_replace_variable_values_no_values():
    test_content = ('<check_type:"Unix">\n'
                    '<custom_item>\n'
                    '  description: "Test value one"\n'
                    '  info : "Test @VAR_ONE@ variable"\n'
                    '</custom_item>\n'
                    '</check_type>')
    assert replace_variable_values(test_content, {}) == test_content
コード例 #3
0
def test_replace_variable_values_simple_content_and_values():
    test_content = ('<check_type:"Unix">\n'
                    '<custom_item>\n'
                    '  description: "Test value one"\n'
                    '  info : "Test @VAR_ONE@ variable"\n'
                    '</custom_item>\n'
                    '</check_type>')
    test_values = { 'VAR_ONE': 'Value One' }
    expected = test_content.replace('@VAR_ONE@', 'Value One')
    assert replace_variable_values(test_content, test_values) == expected
コード例 #4
0
def test_replace_variable_values_simple_content_and_values():
    test_content = ('<check_type:"Unix">\n'
                    '<custom_item>\n'
                    '  description: "Test value one"\n'
                    '  info : "Test @VAR_ONE@ variable"\n'
                    '</custom_item>\n'
                    '</check_type>')
    test_values = {'VAR_ONE': 'Value One'}
    expected = test_content.replace('@VAR_ONE@', 'Value One')
    assert replace_variable_values(test_content, test_values) == expected
コード例 #5
0
def test_replace_variable_values_multiple_values_in_same_line():
    test_content = ('<check_type:"Unix">\n'
                    '<custom_item>\n'
                    '  description: "Test value one and two"\n'
                    '  info : "Test @VAR_ONE@ and @VAR_TWO@ variable"\n'
                    '</custom_item>\n'
                    '</check_type>')
    test_values = { 'VAR_ONE': 'Value One', 'VAR_TWO': 'Value Two' }
    prepped = test_content.replace('@VAR_ONE@', 'Value One')
    expected = prepped.replace('@VAR_TWO@', 'Value Two')
    assert replace_variable_values(test_content, test_values) == expected
コード例 #6
0
def test_replace_variable_values_multiple_values_in_same_line():
    test_content = ('<check_type:"Unix">\n'
                    '<custom_item>\n'
                    '  description: "Test value one and two"\n'
                    '  info : "Test @VAR_ONE@ and @VAR_TWO@ variable"\n'
                    '</custom_item>\n'
                    '</check_type>')
    test_values = {'VAR_ONE': 'Value One', 'VAR_TWO': 'Value Two'}
    prepped = test_content.replace('@VAR_ONE@', 'Value One')
    expected = prepped.replace('@VAR_TWO@', 'Value Two')
    assert replace_variable_values(test_content, test_values) == expected
コード例 #7
0
def test_replace_variable_values_prior_replaced_value():
    test_content = ('<check_type:"Unix">\n'
                    '<custom_item>\n'
                    '  description: "Test value one and two"\n'
                    '# Note: Variable @VAR_ONE@ replaced with "Other One" in '
                    'field "info".\n'
                    '  info : "Test Other One variable"\n'
                    '</custom_item>\n'
                    '</check_type>')
    test_values = { 'VAR_ONE': 'Value One' }
    expected = test_content.replace(' Other One ', ' Value One ')
    assert replace_variable_values(test_content, test_values) == expected
コード例 #8
0
def test_replace_variable_values_prior_replaced_value():
    test_content = ('<check_type:"Unix">\n'
                    '<custom_item>\n'
                    '  description: "Test value one and two"\n'
                    '# Note: Variable @VAR_ONE@ replaced with "Other One" in '
                    'field "info".\n'
                    '  info : "Test Other One variable"\n'
                    '</custom_item>\n'
                    '</check_type>')
    test_values = {'VAR_ONE': 'Value One'}
    expected = test_content.replace(' Other One ', ' Value One ')
    assert replace_variable_values(test_content, test_values) == expected
コード例 #9
0
def test_replace_variable_values_no_content():
    test_values = { 'VAR_ONE': 'Value One' }
    assert replace_variable_values('', test_values) == ''
コード例 #10
0
def test_replace_variable_values_no_content_or_values():
    assert replace_variable_values('', {}) == ''
コード例 #11
0
def test_replace_variable_values_no_content():
    test_values = {'VAR_ONE': 'Value One'}
    assert replace_variable_values('', test_values) == ''
コード例 #12
0
def test_replace_variable_values_no_content_or_values():
    assert replace_variable_values('', {}) == ''