Пример #1
0
    def __init__(self):
        class DummyCache(object):
            def get_caching_iter(self, image_id, image_checksum, app_iter):
                self.image_checksum = image_checksum

        self.cache = DummyCache()
        self.policy = unit_test_utils.FakePolicyEnforcer()
Пример #2
0
 def setUp(self):
     self.fakens = mock.Mock()
     self.fakeobj = mock.Mock()
     self.fakert = mock.Mock()
     self.fakeprop = mock.Mock()
     self.faketag = mock.Mock()
     self.policy = unit_test_utils.FakePolicyEnforcer()
     super(TestMetadefPolicy, self).setUp()
Пример #3
0
 def setUp(self):
     super(TestImagesController, self).setUp()
     self.db = unit_test_utils.FakeDB()
     self.policy = unit_test_utils.FakePolicyEnforcer()
     self._create_images()
     self.controller = glance.api.v2.images.ImagesController(
         self.db, self.policy)
     glance.store.create_stores()
Пример #4
0
 def setUp(self):
     super(TestTasksController, self).setUp()
     self.db = unit_test_utils.FakeDB()
     self.policy = unit_test_utils.FakePolicyEnforcer()
     self.notifier = unit_test_utils.FakeNotifier()
     self.store = unit_test_utils.FakeStoreAPI()
     self._create_tasks()
     self.controller = glance.api.v2.tasks.TasksController(
         self.db, self.policy, self.notifier, self.store)
Пример #5
0
    def setUp(self):
        super(TestImagesController, self).setUp()

        self.config(verbose=True, debug=True)
        self.notifier = unit_test_utils.FakeNotifier()
        self.controller = glance.api.v2.image_data.ImageDataController(
            db_api=unit_test_utils.FakeDB(),
            store_api=unit_test_utils.FakeStoreAPI(),
            policy_enforcer=unit_test_utils.FakePolicyEnforcer(),
            notifier=self.notifier)
Пример #6
0
 def setUp(self):
     super(TestImageMembersController, self).setUp()
     self.db = unit_test_utils.FakeDB()
     self.store = unit_test_utils.FakeStoreAPI()
     self.policy = unit_test_utils.FakePolicyEnforcer()
     self.notifier = unit_test_utils.FakeNotifier()
     self._create_images()
     self._create_image_members()
     self.controller = glance.api.v2.image_members.ImageMembersController(
         self.db, self.policy, self.notifier, self.store)
     glance_store.create_stores()
    def setUp(self):
        super(TestMultiBackendImagesController, self).setUp()

        self.config(debug=True)
        self.image_repo = FakeImageRepo()
        db = unit_test_utils.FakeDB()
        policy = unit_test_utils.FakePolicyEnforcer()
        notifier = unit_test_utils.FakeNotifier()
        store = unit_test_utils.FakeStoreAPI()
        self.controller = glance.api.v2.image_data.ImageDataController()
        self.controller.gateway = FakeGateway(db, store, notifier, policy,
                                              self.image_repo)
 def setUp(self):
     super(TestImageActionsController, self).setUp()
     self.db = unit_test_utils.FakeDB(initialize=False)
     self.policy = unit_test_utils.FakePolicyEnforcer()
     self.notifier = unit_test_utils.FakeNotifier()
     self.store = unit_test_utils.FakeStoreAPI()
     for i in range(1, 4):
         self.store.data['%s/fake_location_%i' % (BASE_URI, i)] = ('Z', 1)
     self.store_utils = unit_test_utils.FakeStoreUtils(self.store)
     self.controller = image_actions.ImageActionsController(
         self.db, self.policy, self.notifier, self.store)
     self.controller.gateway.store_utils = self.store_utils
     store.create_stores()
Пример #9
0
    def setUp(self):
        super(TestImageMembersController, self).setUp()
        self.db = unit_test_utils.FakeDB(initialize=False)
        self.store = unit_test_utils.FakeStoreAPI()
        self.policy = unit_test_utils.FakePolicyEnforcer()
        self.notifier = unit_test_utils.FakeNotifier()
        self._create_images()
        self._create_image_members()
        self.controller = glance.api.v2.image_members.ImageMembersController(
            self.db, self.policy, self.notifier, self.store)
        glance_store.register_opts(CONF)

        self.config(default_store='filesystem',
                    filesystem_store_datadir=self.test_dir,
                    group="glance_store")

        glance_store.create_stores()
Пример #10
0
 def setUp(self):
     super(TestMetadefsControllers, self).setUp()
     self.db = unit_test_utils.FakeDB()
     self.policy = unit_test_utils.FakePolicyEnforcer()
     self._create_namespaces()
     self._create_properties()
     self._create_objects()
     self._create_resource_types()
     self._create_namespaces_resource_types()
     self.namespace_controller = namespaces.NamespaceController(
         self.db, self.policy)
     self.property_controller = \
         properties.NamespacePropertiesController(self.db, self.policy)
     self.object_controller = objects.MetadefObjectsController(
         self.db, self.policy)
     self.rt_controller = resource_types.ResourceTypeController(
         self.db, self.policy)
Пример #11
0
    def setUp(self):
        super(TestImagesController, self).setUp()

        self.config(debug=True)
        self.image_repo = FakeImageRepo()
        db = unit_test_utils.FakeDB()
        policy = unit_test_utils.FakePolicyEnforcer()
        notifier = unit_test_utils.FakeNotifier()
        store = unit_test_utils.FakeStoreAPI()
        self.controller = glance.api.v2.image_data.ImageDataController()
        self.controller.gateway = FakeGateway(db, store, notifier, policy,
                                              self.image_repo)
        # FIXME(abhishekk): Everything is fake in this test, so mocked the
        # image mutable_check, Later we need to fix these tests to use
        # some realistic data
        patcher = mock.patch('glance.api.v2.policy.check_is_image_mutable')
        patcher.start()
        self.addCleanup(patcher.stop)
Пример #12
0
    def __init__(self):
        self.serializer = FakeImageSerializer()

        class DummyCache(object):
            def __init__(self):
                self.deleted_images = []

            def is_cached(self, image_id):
                return True

            def get_caching_iter(self, image_id, image_checksum, app_iter):
                pass

            def delete_cached_image(self, image_id):
                self.deleted_images.append(image_id)

            def get_image_size(self, image_id):
                pass

        self.cache = DummyCache()
        self.policy = unit_test_utils.FakePolicyEnforcer()
Пример #13
0
 def setUp(self):
     self.policy = unit_test_utils.FakePolicyEnforcer()
     self.member_repo = glance.api.policy.ImageMemberRepoProxy(
         MemberRepoStub(), {}, self.policy)
     super(TestMemberPolicy, self).setUp()
Пример #14
0
 def setUp(self):
     super(TestTasksControllerPolicies, self).setUp()
     self.db = unit_test_utils.FakeDB()
     self.policy = unit_test_utils.FakePolicyEnforcer()
     self.controller = glance.api.v2.tasks.TasksController(
         self.db, self.policy)
Пример #15
0
 def setUp(self):
     self.image_stub = ImageStub(UUID1)
     self.image_repo_stub = ImageRepoStub()
     self.image_factory_stub = ImageFactoryStub()
     self.policy = unit_test_utils.FakePolicyEnforcer()
     super(TestImagePolicy, self).setUp()
Пример #16
0
 def setUp(self):
     self.task_stub = TaskStub(UUID1)
     self.task_repo_stub = TaskRepoStub()
     self.task_factory_stub = TaskFactoryStub()
     self.policy = unit_test_utils.FakePolicyEnforcer()
     super(TestTaskPolicy, self).setUp()
Пример #17
0
 def setUp(self):
     super(TestImageDataControllerPolicies, self).setUp()
     self.db = unit_test_utils.FakeDB()
     self.policy = unit_test_utils.FakePolicyEnforcer()
     self.controller = glance.api.v2.image_data.ImageDataController(
         self.db, policy_enforcer=self.policy)
Пример #18
0
 def setUp(self):
     super(TestTasksDeserializer, self).setUp()
     self.policy = unit_test_utils.FakePolicyEnforcer()
     self.deserializer = glance.api.v2.tasks.RequestDeserializer(
         policy_engine=self.policy)