Example #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'
     )
Example #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'
     )
Example #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=')
     )
Example #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')
     )
Example #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=')
     )
Example #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')
     )
Example #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')
     )
Example #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')
     )
Example #9
0
 def test_no_interpolation(self):
     resp = ResponseFactory()
     url = interpolate_url('http://example.com', resp)
     assert url == 'http://example.com'
Example #10
0
 def test_no_interpolation(self):
     resp = ResponseFactory()
     url = interpolate_url('http://example.com', resp)
     assert url == 'http://example.com'