Пример #1
0
    def setUp(self):

        self.logger = debug_logger('proxy-server')
        self.storage = FakeStorageAPI(namespace='NS',
                                      timeouts={},
                                      logger=self.logger)

        self.app = PatchedObjControllerApp({'sds_namespace': "NS"},
                                           account_ring=FakeRing(),
                                           container_ring=FakeRing(),
                                           storage=self.storage,
                                           logger=self.logger)
        self.app.container_info = dict(self.container_info)
        self.storage.account.account_show = Mock(
            return_value={
                'ctime': 0,
                'mtime': 0,
                'containers': 1,
                'objects': 1,
                'bytes': 2,
                'metadata': {}
            })
        self.storage.container.container_get_properties = Mock(return_value={
            'properties': {},
            'system': {}
        })
Пример #2
0
    def setUp(self):
        self.logger = debug_logger('proxy-server')
        self.storage = FakeStorageAPI(logger=self.logger)

        self.app = proxy_server.Application(
            {'sds_namespace': "TEST"}, FakeMemcache(),
            account_ring=FakeRing(), container_ring=FakeRing(),
            storage=self.storage, logger=self.logger)
Пример #3
0
    def setUp(self):
        self.logger = debug_logger('proxy-server')
        self.storage = FakeStorageAPI(logger=self.logger)

        self.app = proxy_server.Application(
            {'sds_namespace': "TEST"}, FakeMemcache(),
            account_ring=FakeRing(), container_ring=FakeRing(),
            storage=self.storage, logger=self.logger)
Пример #4
0
    def setUp(self):

        self.logger = debug_logger('proxy-server')
        self.storage = FakeStorageAPI(logger=self.logger)
        self.storage.account.account_show = Mock(return_value={
            'containers': 0,
            'objects': 0,
            'bytes': 0,
            'ctime': 0,
            'metadata': {}
        })

        self.account_info = {
            'status': 200,
            'container_count': '10',
            'total_object_count': '100',
            'bytes': '1000',
            'meta': {},
            'sysmeta': {}
        }

        self.app = proxy_server.Application({'sds_namespace': 'NS'},
                                            FakeMemcache(),
                                            account_ring=FakeRing(),
                                            container_ring=FakeRing(),
                                            storage=self.storage,
                                            logger=self.logger)

        class FakeAccountInfoContainerController(
                proxy_server.ContainerController):
            def account_info(controller, *args, **kwargs):
                patch_path = 'swift.proxy.controllers.base.get_info'
                with patch(patch_path) as mock_get_info:
                    mock_get_info.return_value = dict(self.account_info)
                    return super(FakeAccountInfoContainerController,
                                 controller).account_info(*args, **kwargs)

        _orig_get_controller = self.app.get_controller

        def wrapped_get_controller(*args, **kwargs):
            with patch('swift.proxy.server.ContainerController',
                       new=FakeAccountInfoContainerController):
                return _orig_get_controller(*args, **kwargs)

        self.app.get_controller = wrapped_get_controller
Пример #5
0
    def setUp(self):

        self.logger = debug_logger('proxy-server')
        self.storage = FakeStorageAPI(logger=self.logger)
        self.storage.account.account_show = Mock(return_value={
            'containers': 0,
            'objects': 0,
            'bytes': 0,
            'ctime': 0,
            'metadata': {}})

        self.account_info = {
            'status': 200,
            'container_count': '10',
            'total_object_count': '100',
            'bytes': '1000',
            'meta': {},
            'sysmeta': {}
        }

        self.app = proxy_server.Application(
            {'sds_namespace': 'NS'}, FakeMemcache(), account_ring=FakeRing(),
            container_ring=FakeRing(), storage=self.storage,
            logger=self.logger)

        class FakeAccountInfoContainerController(
                proxy_server.ContainerController):

            def account_info(controller, *args, **kwargs):
                patch_path = 'swift.proxy.controllers.base.get_info'
                with patch(patch_path) as mock_get_info:
                    mock_get_info.return_value = dict(self.account_info)
                    return super(FakeAccountInfoContainerController,
                                 controller).account_info(
                                    *args, **kwargs)
        _orig_get_controller = self.app.get_controller

        def wrapped_get_controller(*args, **kwargs):
            with patch('swift.proxy.server.ContainerController',
                       new=FakeAccountInfoContainerController):
                return _orig_get_controller(*args, **kwargs)
        self.app.get_controller = wrapped_get_controller
Пример #6
0
    def setUp(self):

        self.logger = debug_logger('proxy-server')
        self.storage = FakeStorageAPI(
            namespace='NS', timeouts={}, logger=self.logger)

        self.app = PatchedObjControllerApp(
            {'sds_namespace': "NS"}, FakeMemcache(), account_ring=FakeRing(),
            container_ring=FakeRing(), storage=self.storage,
            logger=self.logger)
        self.app.container_info = dict(self.container_info)
        self.storage.account.account_show = Mock(
            return_value={
                'ctime': 0,
                'containers': 1,
                'objects': 1,
                'bytes': 2,
                'metadata': {}
                })
        self.storage.container.container_get_properties = Mock(
                return_value={'properties': {}, 'system': {}})