def test_get_substituted_contents_substitutes_correctly(): """ Basic test to make sure Substitutions can get applied correctly. """ sub_one = substitute.Substitution('foo', 'bar', False) sub_two = substitute.Substitution('bar\n\n', 'baz\n', True) start = 'foo\n\n something else\n\n bar\n\n' target = 'baz\n something else\n\n baz\n' subs = [sub_one, sub_two] actual = util.get_substituted_contents(start, subs) assert actual == target
def test_get_substituted_contents_substitutes_correctly(): """ Basic test to make sure Substitutions can get applied correctly. """ sub_one = substitute.Substitution('foo', 'bar', False) sub_two = substitute.Substitution('bar\n\n', 'baz\n', True) start = 'foo\n\n something else\n\n bar\n\n' target = 'baz\n something else\n\n baz\n' subs = [sub_one, sub_two] actual = util.get_substituted_contents(start, subs) assert_equal(actual, target)
def test_get_substituted_contents_substitutes_calls_correct_methods(): """ The get_substituted_contents method calls things in the correct order. """ sub_one = Mock(auto_spec=substitute.Substitution) sub_one_result = 'result of sub one' sub_one.apply_and_get_result.return_value = sub_one_result sub_two = Mock(auto_spec=substitute.Substitution) sub_two_result = 'result of sub two' sub_two.apply_and_get_result.return_value = sub_two_result starting_contents = 'the string we should be substituting into' target = sub_two_result subs = [sub_one, sub_two] actual = util.get_substituted_contents(starting_contents, subs) sub_one.apply_and_get_result.assert_called_once_with(starting_contents) sub_two.apply_and_get_result.assert_called_once_with(sub_one_result) assert actual == target
def test_get_substituted_contents_substitutes_calls_correct_methods(): """ The get_substituted_contents method calls things in the correct order. """ sub_one = Mock(auto_spec=substitute.Substitution) sub_one_result = 'result of sub one' sub_one.apply_and_get_result.return_value = sub_one_result sub_two = Mock(auto_spec=substitute.Substitution) sub_two_result = 'result of sub two' sub_two.apply_and_get_result.return_value = sub_two_result starting_contents = 'the string we should be substituting into' target = sub_two_result subs = [sub_one, sub_two] actual = util.get_substituted_contents(starting_contents, subs) sub_one.apply_and_get_result.assert_called_once_with(starting_contents) sub_two.apply_and_get_result.assert_called_once_with(sub_one_result) assert_equal(actual, target)
def test_get_substituted_contents_handles_empty_subs(): """Nothing should be formatted if there are no substitutions.""" raw_contents = 'this should not be subbed' actual = util.get_substituted_contents(raw_contents, []) assert actual == raw_contents
def test_get_substituted_contents_handles_empty_subs(): """Nothing should be formatted if there are no substitutions.""" raw_contents = 'this should not be subbed' actual = util.get_substituted_contents(raw_contents, []) assert_equal(actual, raw_contents)