Esempio n. 1
0
 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'
     )
Esempio n. 2
0
 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'
     )
Esempio n. 3
0
 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=')
     )
Esempio n. 4
0
 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')
     )
Esempio n. 5
0
 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=')
     )
Esempio n. 6
0
 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')
     )
Esempio n. 7
0
 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')
     )
Esempio n. 8
0
 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')
     )
Esempio n. 9
0
 def test_no_interpolation(self):
     resp = ResponseFactory()
     url = interpolate_url('http://example.com', resp)
     assert url == 'http://example.com'
Esempio n. 10
0
 def test_no_interpolation(self):
     resp = ResponseFactory()
     url = interpolate_url('http://example.com', resp)
     assert url == 'http://example.com'