Exemplo n.º 1
0
 def set_mock_items(*items):
     db_api.__db_items = copy.copy(items)
     db_api.get_items.side_effect = (
         tools.get_db_api_get_items(*db_api.__db_items))
     db_api.get_item_by_id.side_effect = (
         tools.get_db_api_get_item_by_id(*db_api.__db_items))
     db_api.get_items_by_ids.side_effect = (
         tools.get_db_api_get_items_by_ids(*db_api.__db_items))
     db_api.get_items_ids.side_effect = (
         tools.get_db_api_get_items_ids(*db_api.__db_items))
Exemplo n.º 2
0
 def set_mock_db_items(self, *items):
     self._db_items = copy.copy(items)
     self.db_api.get_items.side_effect = (tools.get_db_api_get_items(
         *self._db_items))
     self.db_api.get_item_by_id.side_effect = (
         tools.get_db_api_get_item_by_id(*self._db_items))
     self.db_api.get_items_by_ids.side_effect = (
         tools.get_db_api_get_items_by_ids(*self._db_items))
     self.db_api.get_items_ids.side_effect = (
         tools.get_db_api_get_items_ids(*self._db_items))
Exemplo n.º 3
0
 def set_mock_items(*items):
     db_api.__db_items = copy.copy(items)
     db_api.get_items.side_effect = (tools.get_db_api_get_items(
         *db_api.__db_items))
     db_api.get_item_by_id.side_effect = (
         tools.get_db_api_get_item_by_id(*db_api.__db_items))
     db_api.get_items_by_ids.side_effect = (
         tools.get_db_api_get_items_by_ids(*db_api.__db_items))
     db_api.get_items_ids.side_effect = (tools.get_db_api_get_items_ids(
         *db_api.__db_items))
Exemplo n.º 4
0
 def set_mock_db_items(self, *items):
     self._db_items = copy.copy(items)
     self.db_api.get_items.side_effect = (
         tools.get_db_api_get_items(*self._db_items))
     self.db_api.get_item_by_id.side_effect = (
         tools.get_db_api_get_item_by_id(*self._db_items))
     self.db_api.get_items_by_ids.side_effect = (
         tools.get_db_api_get_items_by_ids(*self._db_items))
     self.db_api.get_items_ids.side_effect = (
         tools.get_db_api_get_items_ids(*self._db_items))
Exemplo n.º 5
0
    def test_get_db_items(self, db_api):
        describer = image_api.ImageDescriber()
        describer.context = base.create_context()

        # NOTE(ft): the first requested image appears is user owend and public,
        # the second is absent
        db_api.get_items.side_effect = (tools.get_db_api_get_items())
        db_api.get_items_by_ids.side_effect = (
            tools.get_db_api_get_items_by_ids(fakes.DB_IMAGE_1))
        db_api.get_public_items.side_effect = [[fakes.DB_IMAGE_1], [], []]

        describer.ids = set([fakes.ID_EC2_IMAGE_1, fakes.ID_EC2_IMAGE_2])
        self.assertRaises(exception.InvalidAMIIDNotFound,
                          describer.get_db_items)
Exemplo n.º 6
0
    def test_get_db_items(self, db_api):
        describer = image_api.ImageDescriber()
        describer.context = base.create_context()

        # NOTE(ft): the first requested image appears is user owend and public,
        # the second is absent
        db_api.get_items.side_effect = (
            tools.get_db_api_get_items())
        db_api.get_items_by_ids.side_effect = (
            tools.get_db_api_get_items_by_ids(fakes.DB_IMAGE_1))
        db_api.get_public_items.side_effect = [
            [fakes.DB_IMAGE_1], [], []]

        describer.ids = set([fakes.ID_EC2_IMAGE_1, fakes.ID_EC2_IMAGE_2])
        self.assertRaises(exception.InvalidAMIIDNotFound,
                          describer.get_db_items)