def test_unicode(self): resp = ResponseFactory( happy=True, platform=u'unicode \xca', ) url = interpolate_url( 'http://example.com?platform={PLATFORM}', resp ) assert ( url == 'http://example.com?platform=unicode+%C3%8A' )
def test_empty_values(self): resp = ResponseFactory( happy=False, product=u'', version=u'', platform=u'', ) url = interpolate_url( 'http://example.com?' + 'happy={HAPPY}&' + 'product={PRODUCT}&' + 'version={VERSION}&' + 'platform={PLATFORM}', resp ) assert ( url == ('http://example.com?' + 'happy=sad&' + 'product=&' + 'version=&' + 'platform=') )
def test_interpolation(self): resp = ResponseFactory( happy=True, product=u'Firefox', version=u'38.0', platform=u'Windows 8.1', ) url = interpolate_url( 'http://example.com?' + 'happy={HAPPY}&' + 'product={PRODUCT}&' + 'version={VERSION}&' + 'platform={PLATFORM}', resp ) assert ( url == ('http://example.com?' + 'happy=happy&' + 'product=Firefox&' + 'version=38.0&' + 'platform=Windows+8.1') )
def test_quoting(self): badchars = '?"\'&=' resp = ResponseFactory( happy=False, product=badchars, version=badchars, platform=badchars, ) url = interpolate_url( 'http://example.com?' + 'happy={HAPPY}&' + 'product={PRODUCT}&' + 'version={VERSION}&' + 'platform={PLATFORM}', resp ) assert ( url == ('http://example.com?' + 'happy=sad&' + 'product=%3F%22%27%26%3D&' 'version=%3F%22%27%26%3D&' 'platform=%3F%22%27%26%3D') )
def test_no_interpolation(self): resp = ResponseFactory() url = interpolate_url('http://example.com', resp) assert url == 'http://example.com'