本文整理汇总了Python中purl.URL.query_params方法的典型用法代码示例。如果您正苦于以下问题:Python URL.query_params方法的具体用法?Python URL.query_params怎么用?Python URL.query_params使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类purl.URL
的用法示例。
在下文中一共展示了URL.query_params方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: UnicodeTests
# 需要导入模块: from purl import URL [as 别名]
# 或者: from purl.URL import query_params [as 别名]
class UnicodeTests(TestCase):
def setUp(self):
self.base = URL('http://127.0.0.1/')
self.text = u'ć'
self.bytes = self.text.encode('utf8')
def test_set_unicode_query_param_value(self):
url = self.base.query_param('q', self.text)
self.assertEqual(self.text, url.query_param('q'))
def test_set_bytestring_query_param_value(self):
url = self.base.query_param('q', self.bytes)
self.assertEqual(self.text, url.query_param('q'))
def test_set_unicode_query_param_key(self):
url = self.base.query_param(self.text, 'value')
self.assertEqual('value', url.query_param(self.text))
def test_set_bytestring_query_param_key(self):
url = self.base.query_param(self.bytes, 'value')
self.assertEqual('value', url.query_param(self.text))
def test_append_unicode_query_param(self):
url = self.base.append_query_param('q', self.text)
self.assertEqual(self.text, url.query_param('q'))
def test_append_bytestring_query_param(self):
url = self.base.append_query_param('q', self.bytes)
self.assertEqual(self.text, url.query_param('q'))
def test_set_unicode_query_params(self):
url = self.base.query_params({'q': self.text})
self.assertEqual(self.text, url.query_param('q'))
def test_set_bytestring_query_params(self):
url = self.base.query_params({'q': self.bytes})
self.assertEqual(self.text, url.query_param('q'))
def test_add_unicode_path_segment(self):
url = self.base.add_path_segment(self.text)
self.assertEqual(self.text, url.path_segment(0))
def test_add_bytestring_path_segment(self):
url = self.base.add_path_segment(self.bytes)
self.assertEqual(self.text, url.path_segment(0))
def test_add_bytestring_path_segment(self):
url = self.base.add_path_segment(self.bytes)
self.assertEqual(self.text, url.path_segment(0))
def test_add_unicode_fragment(self):
url = self.base.fragment(self.text)
self.assertEqual(self.text, url.fragment())
示例2: test_google_login_url
# 需要导入模块: from purl import URL [as 别名]
# 或者: from purl.URL import query_params [as 别名]
def test_google_login_url(google_client, settings):
settings.GOOGLE_CLIENT_ID = '112233'
google_login_url = URL(google_client.get_login_uri())
params = google_login_url.query_params()
callback_url = URL(params['redirect_uri'][0])
func, _args, kwargs = resolve(callback_url.path())
assert func is oauth_callback
assert kwargs['service'] == GOOGLE
assert params['scope'][0] == google_client.scope
assert params['client_id'][0] == str(google_client.client_id)
示例3: test_facebook_login_url
# 需要导入模块: from purl import URL [as 别名]
# 或者: from purl.URL import query_params [as 别名]
def test_facebook_login_url(facebook_client, settings):
settings.FACEBOOK_APP_ID = '112233'
facebook_login_url = URL(facebook_client.get_login_uri())
query = facebook_login_url.query_params()
callback_url = URL(query['redirect_uri'][0])
func, _args, kwargs = resolve(callback_url.path())
assert func is oauth_callback
assert kwargs['service'] == FACEBOOK
assert query['scope'][0] == facebook_client.scope
assert query['client_id'][0] == str(facebook_client.client_id)
示例4: test_google_login_url
# 需要导入模块: from purl import URL [as 别名]
# 或者: from purl.URL import query_params [as 别名]
def test_google_login_url():
google_client = GoogleClient(local_host='local_host')
google_login_url = URL(google_client.get_login_uri())
params = google_login_url.query_params()
callback_url = URL(params['redirect_uri'][0])
func, _args, kwargs = resolve(callback_url.path())
assert func is oauth_callback
assert kwargs['service'] == GOOGLE
assert params['scope'][0] == GoogleClient.scope
assert params['client_id'][0] == str(GoogleClient.client_id)
示例5: test_facebook_login_url
# 需要导入模块: from purl import URL [as 别名]
# 或者: from purl.URL import query_params [as 别名]
def test_facebook_login_url():
facebook_client = FacebookClient(local_host='localhost')
facebook_login_url = URL(facebook_client.get_login_uri())
query = facebook_login_url.query_params()
callback_url = URL(query['redirect_uri'][0])
func, _args, kwargs = resolve(callback_url.path())
assert func is oauth_callback
assert kwargs['service'] == FACEBOOK
assert query['scope'][0] == FacebookClient.scope
assert query['client_id'][0] == str(FacebookClient.client_id)
示例6: test_google_login_url
# 需要导入模块: from purl import URL [as 别名]
# 或者: from purl.URL import query_params [as 别名]
def test_google_login_url(self):
"""Google login url is properly generated"""
google_client = GoogleClient(local_host='local_host')
google_login_url = URL(google_client.get_login_uri())
params = google_login_url.query_params()
callback_url = URL(params['redirect_uri'][0])
func, _args, kwargs = resolve(callback_url.path())
self.assertEquals(func, oauth_callback)
self.assertEquals(kwargs['service'], GOOGLE)
self.assertIn(params['scope'][0], GoogleClient.scope)
self.assertEqual(params['client_id'][0], GoogleClient.client_id)
示例7: test_facebook_login_url
# 需要导入模块: from purl import URL [as 别名]
# 或者: from purl.URL import query_params [as 别名]
def test_facebook_login_url(self):
"""Facebook login url is properly generated"""
facebook_client = FacebookClient(local_host='localhost')
facebook_login_url = URL(facebook_client.get_login_uri())
query = facebook_login_url.query_params()
callback_url = URL(query['redirect_uri'][0])
func, _args, kwargs = resolve(callback_url.path())
self.assertEquals(func, oauth_callback)
self.assertEquals(kwargs['service'], FACEBOOK)
self.assertEqual(query['scope'][0], FacebookClient.scope)
self.assertEqual(query['client_id'][0], FacebookClient.client_id)
示例8: url
# 需要导入模块: from purl import URL [as 别名]
# 或者: from purl.URL import query_params [as 别名]
def url(app, path='/', **query): # pragma: no cover
u = URL(host=app, path=path, query=query)
return str(u.query_params(query))