def test_escaping_hash(self): # http://2.example.org#frag2 assert_equal( render_mandates( {'mandate': json.dumps(['http://2.example.org#frag2'])}), '<a href="http://2.example.org#frag2" target="_blank">http://2.example.org#frag2</a>' )
def test_escaping_invalid_chars(self): assert_equal( render_mandates({ 'mandate': json.dumps(['http://example.com"><script src="nasty.js">']) }), '<a href="http://example.com"><script src="nasty.js">" target="_blank">http://example.com"><script src="nasty.js"></a>' )
def test_escaping_umlaut(self): # http://www.example.org/Durst (umlaut on the u) assert_equal( render_mandates( {'mandate': json.dumps(['http://www.example.org/D\u00fcrst'])}), '<a href="http://www.example.org/D\\u00fcrst" target="_blank">http://www.example.org/D\\u00fcrst</a>' )
def test_escaping_spaces_and_symbols(self): # http://www.example.org/foo bar/qux<>?\^`{|} assert_equal( render_mandates({ 'mandate': json.dumps(['http://www.example.org/foo bar/qux<>?\\\^`{|}']) }), '<a href="http://www.example.org/foo bar/qux<>?\\\\^`{|}" target="_blank">http://www.example.org/foo bar/qux<>?\\\\^`{|}</a>' )
def test_multiple(self): assert_equal( render_mandates({ 'mandate': json.dumps(['http://example.com/a', 'http://example.com/b']) }), '<a href="http://example.com/a" target="_blank">http://example.com/a</a><br>' '<a href="http://example.com/b" target="_blank">http://example.com/b</a>' )
def test_escaping_invalid_chars(self): assert_equal(render_mandates( {'mandate': json.dumps(['http://example.com"><script src="nasty.js">'])}), '<a href="http://example.com"><script src="nasty.js">" target="_blank">http://example.com"><script src="nasty.js"></a>')
def test_single(self): assert_equal( render_mandates({'mandate': json.dumps(['http://example.com'])}), '<a href="http://example.com" target="_blank">http://example.com</a>' )
def test_escaping_hash(self): # http://2.example.org#frag2 assert_equal(render_mandates( {'mandate': json.dumps(['http://2.example.org#frag2'])}), '<a href="http://2.example.org#frag2" target="_blank">http://2.example.org#frag2</a>')
def test_escaping_spaces_and_symbols(self): # http://www.example.org/foo bar/qux<>?\^`{|} assert_equal(render_mandates( {'mandate': json.dumps(['http://www.example.org/foo bar/qux<>?\\\^`{|}'])}), '<a href="http://www.example.org/foo bar/qux<>?\\\\^`{|}" target="_blank">http://www.example.org/foo bar/qux<>?\\\\^`{|}</a>')
def test_escaping_umlaut(self): # http://www.example.org/Durst (umlaut on the u) assert_equal(render_mandates( {'mandate': json.dumps(['http://www.example.org/D\u00fcrst'])}), '<a href="http://www.example.org/D\\u00fcrst" target="_blank">http://www.example.org/D\\u00fcrst</a>')
def test_multiple(self): assert_equal(render_mandates( {'mandate': json.dumps(['http://example.com/a', 'http://example.com/b'])}), '<a href="http://example.com/a" target="_blank">http://example.com/a</a><br>' '<a href="http://example.com/b" target="_blank">http://example.com/b</a>')
def test_single(self): assert_equal(render_mandates( {'mandate': json.dumps(['http://example.com'])}), '<a href="http://example.com" target="_blank">http://example.com</a>')