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


Python Channel.save方法代码示例

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


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

示例1: test_send_message

# 需要导入模块: from junebug.channel import Channel [as 别名]
# 或者: from junebug.channel.Channel import save [as 别名]
    def test_send_message(self):
        '''Sending a message should place the message on the queue for the
        channel'''
        properties = self.create_channel_properties()
        config = yield self.create_channel_config()
        redis = yield self.get_redis()
        channel = Channel(redis, config, properties, 'test-channel')
        yield channel.save()
        yield channel.start(self.service)
        resp = yield self.post('/channels/test-channel/messages/', {
            'to': '+1234', 'content': 'foo', 'from': None})
        yield self.assert_response(
            resp, http.OK, 'message sent', {
                'to': '+1234',
                'channel_id': 'test-channel',
                'from': None,
                'reply_to': None,
                'channel_data': {},
                'content': 'foo',
            }, ignore=['timestamp', 'message_id'])

        [message] = self.get_dispatched_messages('test-channel.outbound')
        message_id = (yield resp.json())['result']['message_id']
        self.assertEqual(message['message_id'], message_id)

        event_url = yield self.api.outbounds.load_event_url(
            'test-channel', message['message_id'])
        self.assertEqual(event_url, None)
开发者ID:westerncapelabs,项目名称:junebug,代码行数:30,代码来源:test_api.py

示例2: create_channel

# 需要导入模块: from junebug.channel import Channel [as 别名]
# 或者: from junebug.channel.Channel import save [as 别名]
    def create_channel(
            self, service, redis, transport_class=None,
            properties=default_channel_properties, id=None, config=None,
            plugins=[]):
        '''Creates and starts, and saves a channel, with a
        TelnetServerTransport transport'''
        self.patch(junebug.logging_service, 'LogFile', DummyLogFile)
        if transport_class is None:
            transport_class = 'vumi.transports.telnet.TelnetServerTransport'

        properties = deepcopy(properties)
        logpath = self.mktemp()
        if config is None:
            config = yield self.create_channel_config(
                channels={
                    properties['type']: transport_class
                },
                logging_path=logpath)

        channel = Channel(
            redis, config, properties, id=id, plugins=plugins)
        yield channel.start(self.service)

        properties['config']['transport_name'] = channel.id

        yield channel.save()
        self.addCleanup(channel.stop)
        returnValue(channel)
开发者ID:BantouTelecom,项目名称:junebug,代码行数:30,代码来源:helpers.py

示例3: test_send_message_event_url

# 需要导入模块: from junebug.channel import Channel [as 别名]
# 或者: from junebug.channel.Channel import save [as 别名]
    def test_send_message_event_url(self):
        '''Sending a message with a specified event url should store the event
        url for sending events in the future'''
        properties = self.create_channel_properties()
        config = yield self.create_channel_config()
        redis = yield self.get_redis()
        channel = Channel(redis, config, properties, 'test-channel')
        yield channel.save()
        yield channel.start(self.service)
        resp = yield self.post('/channels/test-channel/messages/', {
            'to': '+1234', 'content': 'foo', 'from': None,
            'event_url': 'http://test.org'})
        yield self.assert_response(
            resp, http.OK, 'message sent', {
                'to': '+1234',
                'channel_id': 'test-channel',
                'from': None,
                'reply_to': None,
                'channel_data': {},
                'content': 'foo',
            }, ignore=['timestamp', 'message_id'])

        event_url = yield self.api.outbounds.load_event_url(
            'test-channel', (yield resp.json())['result']['message_id'])
        self.assertEqual(event_url, 'http://test.org')
开发者ID:westerncapelabs,项目名称:junebug,代码行数:27,代码来源:test_api.py

示例4: test_delete_channel

# 需要导入模块: from junebug.channel import Channel [as 别名]
# 或者: from junebug.channel.Channel import save [as 别名]
    def test_delete_channel(self):
        config = yield self.create_channel_config()
        properties = self.create_channel_properties()
        channel = Channel(self.redis, config, properties, 'test-channel')
        yield channel.save()
        yield channel.start(self.service)

        self.assertTrue('test-channel' in self.service.namedServices)
        properties = yield self.redis.get('test-channel:properties')
        self.assertNotEqual(properties, None)

        resp = yield self.delete('/channels/test-channel')
        yield self.assert_response(resp, http.OK, 'channel deleted', {})

        self.assertFalse('test-channel' in self.service.namedServices)
        properties = yield self.redis.get('test-channel:properties')
        self.assertEqual(properties, None)

        resp = yield self.delete('/channels/test-channel')
        yield self.assert_response(
            resp, http.NOT_FOUND, 'channel not found', {
                'errors': [{
                    'message': '',
                    'type': 'ChannelNotFound',
                }]
            })

        self.assertFalse('test-channel' in self.service.namedServices)
        properties = yield self.redis.get('test-channel:properties')
        self.assertEqual(properties, None)
开发者ID:westerncapelabs,项目名称:junebug,代码行数:32,代码来源:test_api.py

示例5: create_channel

# 需要导入模块: from junebug.channel import Channel [as 别名]
# 或者: from junebug.channel.Channel import save [as 别名]
 def create_channel(self, request, body):
     '''Create a channel'''
     channel = Channel(
         self.redis, self.config, body)
     yield channel.save()
     yield channel.start(self.service)
     returnValue(response(
         request, 'channel created', (yield channel.status())))
开发者ID:westerncapelabs,项目名称:junebug,代码行数:10,代码来源:api.py

示例6: create_channel

# 需要导入模块: from junebug.channel import Channel [as 别名]
# 或者: from junebug.channel.Channel import save [as 别名]
 def create_channel(self, request, body):
     '''Create a channel'''
     channel = Channel(
         self.redis, self.config, body, self.plugins)
     yield channel.start(self.service)
     yield channel.save()
     returnValue(response(
         request, 'channel created', (yield channel.status()),
         code=http.CREATED))
开发者ID:praekelt,项目名称:junebug,代码行数:11,代码来源:api.py

示例7: create_channel

# 需要导入模块: from junebug.channel import Channel [as 别名]
# 或者: from junebug.channel.Channel import save [as 别名]
    def create_channel(self, request, body):
        '''Create a channel'''
        if not (body.get('mo_url') or body.get('amqp_queue')):
            raise ApiUsageError(
                'One or both of "mo_url" and "amqp_queue" must be specified')

        channel = Channel(
            self.redis, self.config, body, self.plugins)
        yield channel.save()
        yield channel.start(self.service)
        returnValue(response(
            request, 'channel created', (yield channel.status())))
开发者ID:BantouTelecom,项目名称:junebug,代码行数:14,代码来源:api.py

示例8: test_get_channel

# 需要导入模块: from junebug.channel import Channel [as 别名]
# 或者: from junebug.channel.Channel import save [as 别名]
    def test_get_channel(self):
        properties = self.create_channel_properties()
        config = yield self.create_channel_config()
        redis = yield self.get_redis()
        channel = Channel(redis, config, properties, u'test-channel')
        yield channel.save()
        yield channel.start(self.service)
        resp = yield self.get('/channels/test-channel')

        yield self.assert_response(
            resp, http.OK, 'channel found', conjoin(properties, {
                'status': {},
                'id': 'test-channel',
            }))
开发者ID:westerncapelabs,项目名称:junebug,代码行数:16,代码来源:test_api.py

示例9: create_channel

# 需要导入模块: from junebug.channel import Channel [as 别名]
# 或者: from junebug.channel.Channel import save [as 别名]
 def create_channel(
         self, service, redis, transport_class,
         properties=default_channel_properties, id=None):
     '''Creates and starts, and saves a channel, with a
     TelnetServerTransport transport'''
     properties = deepcopy(properties)
     config = yield self.create_channel_config()
     channel = Channel(
         redis, config, properties, id=id)
     properties['config']['transport_name'] = channel.id
     yield channel.start(self.service)
     yield channel.save()
     self.addCleanup(channel.stop)
     returnValue(channel)
开发者ID:westerncapelabs,项目名称:junebug,代码行数:16,代码来源:helpers.py

示例10: test_send_message_message_rate

# 需要导入模块: from junebug.channel import Channel [as 别名]
# 或者: from junebug.channel.Channel import save [as 别名]
    def test_send_message_message_rate(self):
        '''Sending a message should increment the message rate counter'''
        clock = yield self.patch_message_rate_clock()
        channel = Channel(
            (yield self.get_redis()), (yield self.create_channel_config()),
            self.create_channel_properties(), id='test-channel')
        yield channel.save()
        yield channel.start(self.service)

        yield self.post('/channels/test-channel/messages/', {
            'to': '+1234', 'content': 'foo', 'from': None})
        clock.advance(channel.config.metric_window)

        rate = yield self.api.message_rate.get_messages_per_second(
            'test-channel', 'outbound', channel.config.metric_window)
        self.assertEqual(rate, 1.0 / channel.config.metric_window)
开发者ID:BantouTelecom,项目名称:junebug,代码行数:18,代码来源:test_api.py

示例11: test_modify_channel_config_change

# 需要导入模块: from junebug.channel import Channel [as 别名]
# 或者: from junebug.channel.Channel import save [as 别名]
    def test_modify_channel_config_change(self):
        redis = yield self.get_redis()
        properties = self.create_channel_properties()
        config = yield self.create_channel_config()

        channel = Channel(redis, config, properties, 'test-channel')
        yield channel.save()
        yield channel.start(self.service)

        properties['config']['name'] = 'bar'
        resp = yield self.post('/channels/test-channel', properties)

        yield self.assert_response(
            resp, http.OK, 'channel updated', conjoin(properties, {
                'status': {},
                'id': 'test-channel',
            }))
开发者ID:westerncapelabs,项目名称:junebug,代码行数:19,代码来源:test_api.py

示例12: test_modify_channel_no_config_change

# 需要导入模块: from junebug.channel import Channel [as 别名]
# 或者: from junebug.channel.Channel import save [as 别名]
    def test_modify_channel_no_config_change(self):
        properties = self.create_channel_properties()
        config = yield self.create_channel_config()
        redis = yield self.get_redis()

        channel = Channel(redis, config, properties, 'test-channel')
        yield channel.save()
        yield channel.start(self.service)

        resp = yield self.post(
            '/channels/test-channel', {'metadata': {'foo': 'bar'}})

        yield self.assert_response(
            resp, http.OK, 'channel updated', conjoin(properties, {
                'status': {},
                'id': 'test-channel',
                'metadata': {'foo': 'bar'},
            }))
开发者ID:westerncapelabs,项目名称:junebug,代码行数:20,代码来源:test_api.py

示例13: test_send_message_under_character_limit

# 需要导入模块: from junebug.channel import Channel [as 别名]
# 或者: from junebug.channel.Channel import save [as 别名]
 def test_send_message_under_character_limit(self):
     '''If the content length is under the character limit, no errors should
     be returned'''
     properties = self.create_channel_properties(character_limit=100)
     config = yield self.create_channel_config()
     redis = yield self.get_redis()
     channel = Channel(redis, config, properties, id='test-channel')
     yield channel.save()
     yield channel.start(self.service)
     resp = yield self.post('/channels/test-channel/messages/', {
         'to': '+1234', 'content': 'Under the character limit.',
         'from': None})
     yield self.assert_response(
         resp, http.OK, 'message sent', {
             'to': '+1234',
             'channel_id': 'test-channel',
             'from': None,
             'reply_to': None,
             'channel_data': {},
             'content': 'Under the character limit.',
         }, ignore=['timestamp', 'message_id'])
开发者ID:BantouTelecom,项目名称:junebug,代码行数:23,代码来源:test_api.py

示例14: test_send_message_over_character_limit

# 需要导入模块: from junebug.channel import Channel [as 别名]
# 或者: from junebug.channel.Channel import save [as 别名]
 def test_send_message_over_character_limit(self):
     '''If the content length is over the character limit, an error should
     be returned'''
     properties = self.create_channel_properties(character_limit=10)
     config = yield self.create_channel_config()
     redis = yield self.get_redis()
     channel = Channel(redis, config, properties, id='test-channel')
     yield channel.save()
     yield channel.start(self.service)
     resp = yield self.post('/channels/test-channel/messages/', {
         'to': '+1234', 'content': 'Over the character limit.',
         'from': None})
     yield self.assert_response(
         resp, http.BAD_REQUEST, 'message too long', {
             'errors': [{
                 'message':
                     "Message content u'Over the character limit.' "
                     "is of length 25, which is greater than the character "
                     "limit of 10",
                 'type': 'MessageTooLong',
             }],
         })
开发者ID:BantouTelecom,项目名称:junebug,代码行数:24,代码来源:test_api.py

示例15: test_send_message_reply

# 需要导入模块: from junebug.channel import Channel [as 别名]
# 或者: from junebug.channel.Channel import save [as 别名]
    def test_send_message_reply(self):
        '''Sending a reply message should fetch the relevant inbound message,
        use it to construct a reply message, and place the reply message on the
        queue for the channel'''
        channel = Channel(
            redis_manager=(yield self.get_redis()),
            config=(yield self.create_channel_config()),
            properties=self.create_channel_properties(),
            id='test-channel')

        yield channel.save()
        yield channel.start(self.service)

        in_msg = TransportUserMessage(
            from_addr='+2789',
            to_addr='+1234',
            transport_name='test-channel',
            transport_type='_',
            transport_metadata={'foo': 'bar'})

        yield self.api.inbounds.store_vumi_message('test-channel', in_msg)
        expected = in_msg.reply(content='testcontent')
        expected = api_from_message(expected)

        resp = yield self.post('/channels/test-channel/messages/', {
            'reply_to': in_msg['message_id'],
            'content': 'testcontent',
        })

        yield self.assert_response(
            resp, http.OK,
            'message sent',
            omit(expected, 'timestamp', 'message_id'),
            ignore=['timestamp', 'message_id'])

        [message] = self.get_dispatched_messages('test-channel.outbound')
        message_id = (yield resp.json())['result']['message_id']
        self.assertEqual(message['message_id'], message_id)
开发者ID:westerncapelabs,项目名称:junebug,代码行数:40,代码来源:test_api.py


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