示例#1
0
    def test_store_status_overwrite(self):
        '''New statuses override old statuses with the same component, but do
        not affect statuses of different components'''
        store = yield self.create_store()
        status_old = TransportStatus(status='ok',
                                     component='foo',
                                     type='bar',
                                     message='foo')
        status_new = TransportStatus(status='down',
                                     component='foo',
                                     type='bar',
                                     message='foo')
        status_other = TransportStatus(status='ok',
                                       component='bar',
                                       type='bar',
                                       message='foo')

        yield store.store_status('channelid', status_other)
        yield store.store_status('channelid', status_old)
        yield store.store_status('channelid', status_new)

        status_new_redis = yield self.redis.hget('channelid:status', 'foo')
        self.assertEqual(status_new_redis, status_new.to_json())

        status_other_redis = yield self.redis.hget('channelid:status', 'bar')
        self.assertEqual(status_other_redis, status_other.to_json())
示例#2
0
    def test_store_status_overwrite(self):
        '''New statuses override old statuses with the same component, but do
        not affect statuses of different components'''
        store = yield self.create_store()
        status_old = TransportStatus(
            status='ok', component='foo', type='bar', message='foo')
        status_new = TransportStatus(
            status='down', component='foo', type='bar', message='foo')
        status_other = TransportStatus(
            status='ok', component='bar', type='bar', message='foo')

        yield store.store_status('channelid', status_other)
        yield store.store_status('channelid', status_old)
        yield store.store_status('channelid', status_new)

        status_new_redis = yield self.redis.hget('channelid:status', 'foo')
        self.assertEqual(status_new_redis, status_new.to_json())

        status_other_redis = yield self.redis.hget('channelid:status', 'bar')
        self.assertEqual(status_other_redis, status_other.to_json())
示例#3
0
    def test_store_single_status(self):
        '''The single status is stored under the correct key'''
        store = yield self.create_store()
        status = TransportStatus(
            status='ok', component='foo', type='bar', message='foo')
        yield store.store_status('channelid', status)

        status_redis = yield self.redis.hget('channelid:status', 'foo')
        self.assertEqual(status_redis, status.to_json())

        self.assertEqual((yield self.redis.ttl('channelid:status')), None)
示例#4
0
    def test_status_stored_in_redis(self):
        '''The published status gets consumed and stored in redis under the
        correct key'''
        status = TransportStatus(component='foo',
                                 status='ok',
                                 type='bar',
                                 message='Bar')
        yield self.worker.consume_status(status)

        redis_status = yield self.worker.store.redis.hget(
            'testchannel:status', 'foo')

        self.assertEqual(redis_status, status.to_json())
示例#5
0
    def test_store_single_status(self):
        '''The single status is stored under the correct key'''
        store = yield self.create_store()
        status = TransportStatus(status='ok',
                                 component='foo',
                                 type='bar',
                                 message='foo')
        yield store.store_status('channelid', status)

        status_redis = yield self.redis.hget('channelid:status', 'foo')
        self.assertEqual(status_redis, status.to_json())

        self.assertEqual((yield self.redis.ttl('channelid:status')), None)
示例#6
0
    def test_status_stored_in_redis(self):
        '''The published status gets consumed and stored in redis under the
        correct key'''
        status = TransportStatus(
            component='foo',
            status='ok',
            type='bar',
            message='Bar')
        yield self.worker.consume_status(status)

        redis_status = yield self.worker.store.redis.hget(
            'testchannel:status', 'foo')

        self.assertEqual(redis_status, status.to_json())