How to use the webob.multidict.MultiDict function in WebOb

To help you get started, we’ve selected a few WebOb examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Pylons / webob / tests / test_multidict.py View on Github external
def test_no_args(self):
        from webob.multidict import MultiDict

        md = MultiDict()
        self.assertEqual(md._items, [])
github pypa / warehouse / tests / unit / forklift / test_legacy.py View on Github external
def test_fails_with_stdlib_names(self, pyramid_config, db_request, name):
        user = UserFactory.create()
        EmailFactory.create(user=user)
        db_request.user = user
        pyramid_config.testing_securitypolicy(userid=1)
        db_request.POST = MultiDict(
            {
                "metadata_version": "1.2",
                "name": name,
                "version": "1.0",
                "filetype": "sdist",
                "md5_digest": "a fake md5 digest",
                "content": pretend.stub(
                    filename=f"{name}-1.0.tar.gz",
                    file=io.BytesIO(_TAR_GZ_PKG_TESTDATA),
                    type="application/tar",
                ),
            }
        )

        db_request.help_url = pretend.call_recorder(lambda **kw: "/the/help/url/")
github pypa / warehouse / tests / unit / forklift / test_legacy.py View on Github external
def test_full_validate_valid(self, data):
        form = legacy.MetadataForm(MultiDict(data))
        form.full_validate()
github Pylons / webob / tests / test_multidict.py View on Github external
def test_view_list(self):
        from webob.multidict import MultiDict

        d = MultiDict()
        self.assertEqual(d.view_list([1, 2])._items, [1, 2])
github pypa / warehouse / tests / unit / forklift / test_legacy.py View on Github external
Test that if a release with a version like '1.0' exists, that a future
        upload with an equivalent version like '1.0.0' will not make a second
        release
        """
        pyramid_config.testing_securitypolicy(userid=1)

        user = UserFactory.create()
        EmailFactory.create(user=user)
        project = ProjectFactory.create()
        release = ReleaseFactory.create(project=project, version="1.0")
        RoleFactory.create(user=user, project=project)

        db_request.user = user
        db_request.remote_addr = "10.10.10.20"
        db_request.user_agent = "warehouse-tests/6.6.6"
        db_request.POST = MultiDict(
            {
                "metadata_version": "1.2",
                "name": project.name,
                "version": "1.0.0",
                "summary": "This is my summary!",
                "filetype": "sdist",
                "md5_digest": _TAR_GZ_PKG_MD5,
                "content": pretend.stub(
                    filename="{}-{}.tar.gz".format(project.name, "1.0.0"),
                    file=io.BytesIO(_TAR_GZ_PKG_TESTDATA),
                    type="application/tar",
                ),
            }
        )

        storage_service = pretend.stub(store=lambda path, filepath, meta: None)
github LeResKP / xmltool / tests / test_utils.py View on Github external
def test_unflatten_params(self):
        dic = {
            'test:0:test1:value': 'v1',
            'test:1:test1:value': 'v2',
        }
        result = utils.unflatten_params(dic)
        expected = {
            'test': [{'test1': {'value': 'v1'}},
                     {'test1': {'value': 'v2'}}]}
        self.assertEqual(result, expected)

        if not hasattr(webob, 'MultiDict'):
            dic = webob.multidict.MultiDict(dic)
        else:
            dic = webob.MultiDict(dic)
        result = utils.unflatten_params(dic)
        self.assertEqual(result, expected)
github SmartTeleMax / iktomi / tests / unstable / forms / files.py View on Github external
def test_none2empty(self):
        form = FormWithFile(self.env)
        form.accept(MultiDict({'file.file': None,
                               'file.original_name': '',
                               'file.transient_name': '',
                               'file.mode': 'empty',}))
        data = form.python_data
        self.assertEqual(data['file'], None)
github Pylons / webob / tests / test_multidict.py View on Github external
def _get_instance(self, environ=None, **kwargs):
        if environ is None:
            environ = {}
        if kwargs:
            data = multidict.MultiDict(kwargs)
        else:
            data = self.data.copy()
        return self.klass(data, environ)
github hypothesis / h / h / schemas / util.py View on Github external
def _dict_to_multidict(dict_):
    """Convert a validated query param dict back to a ``MultiDict``."""
    result = MultiDict()
    for key, value in dict_.items():
        if isinstance(value, list):
            for item in value:
                result.add(key, item)
        else:
            result.add(key, value)
    return result
github hypothesis / h / h / search / core.py View on Github external
def _search_replies(self, annotation_ids):
        if not self.separate_replies:
            return []

        # The only difference between a search for annotations and a search for
        # replies to annotations is the RepliesMatcher and the params passed to
        # the modifiers.
        response = self._search(
            [query.RepliesMatcher(annotation_ids)] + self._modifiers,
            [],  # Aggregations aren't used in replies.
            MultiDict({"limit": self._replies_limit}),
        )

        if len(response["hits"]["hits"]) < response["hits"]["total"]:
            log.warning(
                "The number of reply annotations exceeded the page size "
                "of the Elasticsearch query. We currently don't handle "
                "this, our search API doesn't support pagination of the "
                "reply set."
            )

        return [hit["_id"] for hit in response["hits"]["hits"]]