Esempio n. 1
0
  def test_remove(self):
    q = furl.Query('a=a&b=b&s=s s')
    assert q == q.remove(['a', 'b'])
    assert str(q) == 's=s+s'

    assert q == q.remove(query=True)
    assert str(q) == ''
 def __call__(
         self,
         request: requests.PreparedRequest) -> requests.PreparedRequest:
     request = super().__call__(request)
     data = furl.Query(request.body)
     data.set([("client_id", self.client_id)])
     request.prepare_body(data.params, files=None)
     return request
Esempio n. 3
0
  def test_basics(self):
    for query in ['', 'asdfasdf', '/asdf/asdf/sdf']:
      q = furl.Query(query)
      assert q.params == {}
      assert str(q) == ''

    q = furl.Query('=asdf')
    assert q.params == {'':'asdf'}
    assert str(q) == '=asdf'

    # URL encoding.
    q = furl.Query('space=a+a&amp=a%26a')
    assert q.params == {'space':'a a', 'amp':'a&a'}
    assert str(q) == 'space=a+a&amp=a%26a' or str(q) == 'amp=a%26a&space=a+a'

    q = furl.Query('space=a a&amp=a^a')
    assert q.params == {'space':'a a', 'amp':'a^a'}
    assert str(q) == 'space=a+a&amp=a%5Ea' or str(q) == 'amp=a%5Ea&space=a+a'

    # Duplicates are truncated.
    q = furl.Query('space=a+a&space=b+b')
    assert q.params == {'space':'a a'}
    assert str(q) == 'space=a+a'
Esempio n. 4
0
  def test_params(self):
    q = furl.Query('a=a&b=b')
    assert q.params == {'a':'a', 'b':'b'}
    q.params['sup'] = 'sup'
    assert q.params == {'a':'a', 'b':'b', 'sup':'sup'}
    del q.params['a']
    assert q.params == {'b':'b', 'sup':'sup'}
    q.params['b'] = 'BLROP'
    assert q.params == {'b':'BLROP', 'sup':'sup'}

    # Non-string parameters are stringified
    q.params.clear()
    q.params[99] = 99
    q.params['int'] = 1
    q.params['float'] = 0.39393
    assert furl.parse_qs(str(q)) == {'int':'1', 'float':'0.39393', '99':'99'}
 def __call__(
         self,
         request: requests.PreparedRequest) -> requests.PreparedRequest:
     request = super().__call__(request)
     token_endpoint = request.url
     assert token_endpoint is not None
     data = furl.Query(request.body)
     client_assertion = self.client_assertion(token_endpoint)
     data.set([
         ("client_id", self.client_id),
         ("client_assertion", client_assertion),
         (
             "client_assertion_type",
             "urn:ietf:params:oauth:client-assertion-type:jwt-bearer",
         ),
     ])
     request.prepare_body(data.params, files=None)
     return request
Esempio n. 6
0
 def test_set(self):
   q = furl.Query('a=a')
   assert q == q.set({'b':'b', 's':'s s'})
   comps = furl.parse_qs(str(q))
   assert comps['b'] == 'b' and comps['s'] == 's s'