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
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
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
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
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
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
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
def test_replace_variable_values_no_content(): test_values = { 'VAR_ONE': 'Value One' } assert replace_variable_values('', test_values) == ''
def test_replace_variable_values_no_content_or_values(): assert replace_variable_values('', {}) == ''
def test_replace_variable_values_no_content(): test_values = {'VAR_ONE': 'Value One'} assert replace_variable_values('', test_values) == ''