当前位置: 首页>>代码示例>>Python>>正文


Python URL.query_params方法代码示例

本文整理汇总了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())
开发者ID:suquant,项目名称:purl,代码行数:56,代码来源:tests.py

示例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)
开发者ID:AlexzanderIvanov,项目名称:saleor,代码行数:12,代码来源:test_registration.py

示例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)
开发者ID:AlexzanderIvanov,项目名称:saleor,代码行数:12,代码来源:test_registration.py

示例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)
开发者ID:3ka5-cat,项目名称:saleor,代码行数:12,代码来源:test_registration.py

示例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)
开发者ID:3ka5-cat,项目名称:saleor,代码行数:12,代码来源:test_registration.py

示例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)
开发者ID:D0han,项目名称:saleor,代码行数:13,代码来源:tests.py

示例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)
开发者ID:D0han,项目名称:saleor,代码行数:13,代码来源:tests.py

示例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))
开发者ID:FieldDB,项目名称:clld,代码行数:5,代码来源:clld_api.py


注:本文中的purl.URL.query_params方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。