コード例 #1
0
    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'
        )
コード例 #2
0
ファイル: test_bucket.py プロジェクト: robbyt/boto
    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")