def test_as_global_default(self, app): '''URL helpers should exists as global function without url param''' url = url_for('site.home', one='value') with app.test_request_context(url): assert_urls_equal( render_template_string("{{ url_rewrite(one='other-value') }}"), full_url('site.home', one='other-value')) assert_urls_equal( render_template_string("{{ url_add(two='other-value') }}"), full_url('site.home', one='value', two='other-value')) assert_urls_equal( render_template_string("{{ url_del(None, 'one') }}"), full_url('site.home')) assert render_template_string("{{ in_url('one') }}") == 'True' assert render_template_string("{{ in_url('one') }}") == 'True' assert render_template_string("{{ in_url('two') }}") == 'False'
def test_rewrite_append(self, app): '''url_rewrite should replace a parameter in the URL if present''' url = url_for('site.home') expected = full_url('site.home', one='value') with app.test_request_context(url): result = render_template_string("{{ url_rewrite(one='value') }}") assert_urls_equal(result, expected)