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


Python jsonutils.dumps函数代码示例

本文整理汇总了Python中zaqar.openstack.common.jsonutils.dumps函数的典型用法代码示例。如果您正苦于以下问题:Python dumps函数的具体用法?Python dumps怎么用?Python dumps使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: test_put_raises_if_missing_fields

    def test_put_raises_if_missing_fields(self):
        path = self.url_prefix + '/flavors/' + str(uuid.uuid1())
        self.simulate_put(path, body=jsonutils.dumps({}))
        self.assertEqual(self.srmock.status, falcon.HTTP_400)

        self.simulate_put(path,
                          body=jsonutils.dumps({'capabilities': {}}))
        self.assertEqual(self.srmock.status, falcon.HTTP_400)
开发者ID:jeffrey4l,项目名称:zaqar,代码行数:8,代码来源:test_flavors.py

示例2: test_put_raises_if_missing_fields

    def test_put_raises_if_missing_fields(self):
        path = self.url_prefix + '/pools/' + str(uuid.uuid1())
        self.simulate_put(path, body=jsonutils.dumps({'weight': 100}))
        self.assertEqual(self.srmock.status, falcon.HTTP_400)

        self.simulate_put(path,
                          body=jsonutils.dumps(
                              {'uri': 'sqlite://:memory:'}))
        self.assertEqual(self.srmock.status, falcon.HTTP_400)
开发者ID:rose,项目名称:zaqar,代码行数:9,代码来源:test_pools.py

示例3: setUp

    def setUp(self):
        super(FlavorsBaseTest, self).setUp()
        self.queue = 'test-queue'
        self.queue_path = self.url_prefix + '/queues/' + self.queue

        self.pool = 'mypool'
        self.pool_path = self.url_prefix + '/pools/' + self.pool
        self.pool_doc = {'weight': 100, 'uri': 'sqlite://:memory:'}
        self.simulate_put(self.pool_path, body=jsonutils.dumps(self.pool_doc))

        self.flavor = 'test-flavor'
        self.doc = {'capabilities': {}, 'pool': 'mypool'}
        self.flavor_path = self.url_prefix + '/flavors/' + self.flavor
        self.simulate_put(self.flavor_path, body=jsonutils.dumps(self.doc))
        self.assertEqual(self.srmock.status, falcon.HTTP_201)
开发者ID:gashe5363,项目名称:zaqar,代码行数:15,代码来源:test_flavors.py

示例4: pools

def pools(test, count, uri, group):
    """A context manager for constructing pools for use in testing.

    Deletes the pools after exiting the context.

    :param test: Must expose simulate_* methods
    :param count: Number of pools to create
    :type count: int
    :returns: (paths, weights, uris, options)
    :rtype: ([six.text_type], [int], [six.text_type], [dict])
    """
    base = test.url_prefix + '/pools/'
    args = [(base + str(i), i,
             {str(i): i})
            for i in range(count)]
    for path, weight, option in args:
        doc = {'weight': weight, 'uri': uri,
               'group': group, 'options': option}
        test.simulate_put(path, body=jsonutils.dumps(doc))

    try:
        yield args
    finally:
        for path, _, _ in args:
            test.simulate_delete(path)
开发者ID:rose,项目名称:zaqar,代码行数:25,代码来源:test_pools.py

示例5: pool

def pool(test, name, weight, uri, group=None, options={}):
    """A context manager for constructing a pool for use in testing.

    Deletes the pool after exiting the context.

    :param test: Must expose simulate_* methods
    :param name: Name for this pool
    :type name: six.text_type
    :type weight: int
    :type uri: six.text_type
    :type options: dict
    :returns: (name, weight, uri, options)
    :rtype: see above
    """
    doc = {'weight': weight, 'uri': uri,
           'group': group, 'options': options}
    path = test.url_prefix + '/pools/' + name

    test.simulate_put(path, body=jsonutils.dumps(doc))

    try:
        yield name, weight, uri, group, options

    finally:
        test.simulate_delete(path)
开发者ID:rose,项目名称:zaqar,代码行数:25,代码来源:test_pools.py

示例6: format

    def format(self, record):
        message = {'message': record.getMessage(),
                   'asctime': self.formatTime(record, self.datefmt),
                   'name': record.name,
                   'msg': record.msg,
                   'args': record.args,
                   'levelname': record.levelname,
                   'levelno': record.levelno,
                   'pathname': record.pathname,
                   'filename': record.filename,
                   'module': record.module,
                   'lineno': record.lineno,
                   'funcname': record.funcName,
                   'created': record.created,
                   'msecs': record.msecs,
                   'relative_created': record.relativeCreated,
                   'thread': record.thread,
                   'thread_name': record.threadName,
                   'process_name': record.processName,
                   'process': record.process,
                   'traceback': None}

        if hasattr(record, 'extra'):
            message['extra'] = record.extra

        if record.exc_info:
            message['traceback'] = self.formatException(record.exc_info)

        return jsonutils.dumps(message)
开发者ID:AsherBond,项目名称:marconi,代码行数:29,代码来源:log.py

示例7: flavor

def flavor(test, name, pool, capabilities={}):
    """A context manager for constructing a flavor for use in testing.

    Deletes the flavor after exiting the context.

    :param test: Must expose simulate_* methods
    :param name: Name for this flavor
    :type name: six.text_type
    :type pool: six.text_type
    :type capabilities: dict
    :returns: (name, uri, capabilities)
    :rtype: see above

    """

    doc = {'pool': pool, 'capabilities': capabilities}
    path = test.url_prefix + '/flavors/' + name

    test.simulate_put(path, body=jsonutils.dumps(doc))

    try:
        yield name, pool, capabilities

    finally:
        test.simulate_delete(path)
开发者ID:jeffrey4l,项目名称:zaqar,代码行数:25,代码来源:test_flavors.py

示例8: test_unacceptable_new_ttl

    def test_unacceptable_new_ttl(self, ttl):
        href = self._get_a_claim()

        self.simulate_patch(href, self.project_id,
                            body=jsonutils.dumps({'ttl': ttl}))

        self.assertEqual(self.srmock.status, falcon.HTTP_400)
开发者ID:gashe5363,项目名称:zaqar,代码行数:7,代码来源:test_claims.py

示例9: flavors

def flavors(test, count, pool):
    """A context manager for constructing flavors for use in testing.

    Deletes the flavors after exiting the context.

    :param test: Must expose simulate_* methods
    :param count: Number of pools to create
    :type count: int
    :returns: (paths, pool, capabilities)
    :rtype: ([six.text_type], [six.text_type], [dict])

    """

    base = test.url_prefix + '/flavors/'
    args = sorted([(base + str(i), {str(i): i}, str(i)) for i in range(count)],
                  key=lambda tup: tup[2])
    for path, capabilities, _ in args:
        doc = {'pool': pool, 'capabilities': capabilities}
        test.simulate_put(path, body=jsonutils.dumps(doc))

    try:
        yield args
    finally:
        for path, _, _ in args:
            test.simulate_delete(path)
开发者ID:jeffrey4l,项目名称:zaqar,代码行数:25,代码来源:test_flavors.py

示例10: setUp

    def setUp(self):
        super(MessagesBaseTest, self).setUp()

        self.default_message_ttl = self.boot.transport._defaults.message_ttl

        if self.conf.pooling:
            for i in range(4):
                uri = self.conf['drivers:storage:mongodb'].uri
                doc = {'weight': 100, 'uri': uri}
                self.simulate_put(self.url_prefix + '/pools/' + str(i),
                                  body=jsonutils.dumps(doc))
                self.assertEqual(self.srmock.status, falcon.HTTP_201)

        self.project_id = '7e55e1a7e'
        self.headers = {
            'Client-ID': str(uuid.uuid4()),
            'X-Project-ID': self.project_id
        }

        # TODO(kgriffs): Add support in self.simulate_* for a "base path"
        # so that we don't have to concatenate against self.url_prefix
        # all over the place.
        self.queue_path = self.url_prefix + '/queues/fizbit'
        self.messages_path = self.queue_path + '/messages'

        doc = '{"_ttl": 60}'
        self.simulate_put(self.queue_path, body=doc, headers=self.headers)
开发者ID:jeffrey4l,项目名称:zaqar,代码行数:27,代码来源:test_messages.py

示例11: _prepare_messages

    def _prepare_messages(self, count):
        doc = {'messages': [{'body': 239, 'ttl': 300}] * count}
        body = jsonutils.dumps(doc)
        self.simulate_post(self.messages_path, body=body,
                           headers=self.headers)

        self.assertEqual(self.srmock.status, falcon.HTTP_201)
开发者ID:rose,项目名称:zaqar,代码行数:7,代码来源:test_default_limits.py

示例12: setUp

    def setUp(self):
        super(MessagesBaseTest, self).setUp()

        if self.conf.pooling:
            for i in range(4):
                uri = self.conf['drivers:management_store:mongodb'].uri
                doc = {'weight': 100, 'uri': uri}
                self.simulate_put(self.url_prefix + '/pools/' + str(i),
                                  body=jsonutils.dumps(doc))
                self.assertEqual(self.srmock.status, falcon.HTTP_201)

        self.project_id = '7e55e1a7e'

        # TODO(kgriffs): Add support in self.simulate_* for a "base path"
        # so that we don't have to concatenate against self.url_prefix
        # all over the place.
        self.queue_path = self.url_prefix + '/queues/fizbit'
        self.messages_path = self.queue_path + '/messages'

        doc = '{"_ttl": 60}'
        self.simulate_put(self.queue_path, self.project_id, body=doc)

        # NOTE(kgriffs): Also register without a project for tests
        # that do not specify a project.
        #
        # TODO(kgriffs): Should a project id always be required or
        # automatically supplied in the simulate_* methods?
        self.simulate_put(self.queue_path, body=doc)

        self.headers = {
            'Client-ID': str(uuid.uuid4()),
        }
开发者ID:rose,项目名称:zaqar,代码行数:32,代码来源:test_messages.py

示例13: test_unacceptable_ttl

    def test_unacceptable_ttl(self, ttl):
        doc = {'messages': [{'ttl': ttl, 'body': None}]}

        self.simulate_post(self.queue_path + '/messages',
                           body=jsonutils.dumps(doc),
                           headers=self.headers)

        self.assertEqual(self.srmock.status, falcon.HTTP_400)
开发者ID:jeffrey4l,项目名称:zaqar,代码行数:8,代码来源:test_messages.py

示例14: test_queue_create_no_flavor

    def test_queue_create_no_flavor(self):
        metadata = {'_flavor': self.flavor}

        self.simulate_delete(self.flavor_path)
        self.assertEqual(self.srmock.status, falcon.HTTP_204)

        self.simulate_put(self.queue_path, body=jsonutils.dumps(metadata))
        self.assertEqual(self.srmock.status, falcon.HTTP_400)
开发者ID:jeffrey4l,项目名称:zaqar,代码行数:8,代码来源:test_flavors.py

示例15: setUp

 def setUp(self):
     super(PoolsBaseTest, self).setUp()
     self.doc = {'weight': 100,
                 'group': 'mygroup',
                 'uri': 'sqlite://:memory:'}
     self.pool = self.url_prefix + '/pools/' + str(uuid.uuid1())
     self.simulate_put(self.pool, body=jsonutils.dumps(self.doc))
     self.assertEqual(self.srmock.status, falcon.HTTP_201)
开发者ID:rose,项目名称:zaqar,代码行数:8,代码来源:test_pools.py


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