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


Python Bucket._get_all_query_args方法代码示例

本文整理汇总了Python中boto.s3.bucket.Bucket._get_all_query_args方法的典型用法代码示例。如果您正苦于以下问题:Python Bucket._get_all_query_args方法的具体用法?Python Bucket._get_all_query_args怎么用?Python Bucket._get_all_query_args使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在boto.s3.bucket.Bucket的用法示例。


在下文中一共展示了Bucket._get_all_query_args方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test__get_all_query_args

# 需要导入模块: from boto.s3.bucket import Bucket [as 别名]
# 或者: from boto.s3.bucket.Bucket import _get_all_query_args [as 别名]
    def test__get_all_query_args(self):
        bukket = Bucket()

        # Default.
        qa = bukket._get_all_query_args({})
        self.assertEqual(qa, '')

        # Default with initial.
        qa = bukket._get_all_query_args({}, 'initial=1')
        self.assertEqual(qa, 'initial=1')

        # Single param.
        qa = bukket._get_all_query_args({
            'foo': 'true'
        })
        self.assertEqual(qa, 'foo=true')

        # Single param with initial.
        qa = bukket._get_all_query_args({
            'foo': 'true'
        }, 'initial=1')
        self.assertEqual(qa, 'initial=1&foo=true')

        # Multiple params with all the weird cases.
        multiple_params = {
            'foo': 'true',
            # Ensure Unicode chars get encoded.
            'bar': '☃',
            # Ensure unicode strings with non-ascii characters get encoded
            'baz': u'χ',
            # Underscores are bad, m'kay?
            'some_other': 'thing',
            # Change the variant of ``max-keys``.
            'maxkeys': 0,
            # ``None`` values get excluded.
            'notthere': None,
            # Empty values also get excluded.
            'notpresenteither': '',
        }
        qa = bukket._get_all_query_args(multiple_params)
        self.assertEqual(
            qa,
            'bar=%E2%98%83&baz=%CF%87&foo=true&max-keys=0&some-other=thing'
        )

        # Multiple params with initial.
        qa = bukket._get_all_query_args(multiple_params, 'initial=1')
        self.assertEqual(
            qa,
            'initial=1&bar=%E2%98%83&baz=%CF%87&foo=true&max-keys=0&some-other=thing'
        )
开发者ID:17patelumang,项目名称:boto,代码行数:53,代码来源:test_bucket.py

示例2: test__get_all_query_args

# 需要导入模块: from boto.s3.bucket import Bucket [as 别名]
# 或者: from boto.s3.bucket.Bucket import _get_all_query_args [as 别名]
    def test__get_all_query_args(self):
        bukket = Bucket()

        # Default.
        qa = bukket._get_all_query_args({})
        self.assertEqual(qa, "")

        # Default with initial.
        qa = bukket._get_all_query_args({}, "initial=1")
        self.assertEqual(qa, "initial=1")

        # Single param.
        qa = bukket._get_all_query_args({"foo": "true"})
        self.assertEqual(qa, "foo=true")

        # Single param with initial.
        qa = bukket._get_all_query_args({"foo": "true"}, "initial=1")
        self.assertEqual(qa, "initial=1&foo=true")

        # Multiple params with all the weird cases.
        multiple_params = {
            "foo": "true",
            # Ensure Unicode chars get encoded.
            "bar": "☃",
            # Underscores are bad, m'kay?
            "some_other": "thing",
            # Change the variant of ``max-keys``.
            "maxkeys": 0,
            # ``None`` values get excluded.
            "notthere": None,
            # Empty values also get excluded.
            "notpresenteither": "",
        }
        qa = bukket._get_all_query_args(multiple_params)
        self.assertEqual(qa, "bar=%E2%98%83&max-keys=0&foo=true&some-other=thing")

        # Multiple params with initial.
        qa = bukket._get_all_query_args(multiple_params, "initial=1")
        self.assertEqual(qa, "initial=1&bar=%E2%98%83&max-keys=0&foo=true&some-other=thing")
开发者ID:robbyt,项目名称:boto,代码行数:41,代码来源:test_bucket.py


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