def _do_test(self, sort_dir, sort_key):
        limit = self.PAGE_SIZE
        marker = None

        got_ids = []
        expected_ids = []

        for i in self._sort_results(sort_dir, sort_key):
            expected_ids.append(i['id'])

        while True:
            results = db_api.image_get_all(self.context,
                                           marker=marker,
                                           limit=limit,
                                           sort_key=sort_key,
                                           sort_dir=sort_dir)
            if not results:
                break

            for result in results:
                got_ids.append(result['id'])

            # Prevent this running infinitely in error cases
            self.assertTrue(len(got_ids) < (500 + len(expected_ids)))

            marker = results[-1].id

        self.assertEquals(len(got_ids), len(expected_ids))
        self.assertEquals(got_ids, expected_ids)
Beispiel #2
0
 def test_image_get_all_marker_deleted_showing_deleted(self):
     """Specify a deleted image as a marker if showing deleted images."""
     db_api.image_destroy(self.adm_context, UUID1)
     filters = {'deleted': True}
     images = db_api.image_get_all(self.context, marker=UUID1,
                                   filters=filters)
     self.assertEquals(len(images), 0)
 def test_image_get_all_marker_deleted_showing_deleted(self):
     """Specify a deleted image as a marker if showing deleted images."""
     db_api.image_destroy(self.adm_context, UUID1)
     filters = {'deleted': True}
     images = db_api.image_get_all(self.context, marker=UUID1,
                                   filters=filters)
     self.assertEquals(len(images), 0)
    def _do_test(self, sort_dir, sort_key):
        limit = self.PAGE_SIZE
        marker = None

        got_ids = []
        expected_ids = []

        for i in self._sort_results(sort_dir, sort_key):
            expected_ids.append(i['id'])

        while True:
            results = db_api.image_get_all(self.context,
                                           marker=marker,
                                           limit=limit,
                                           sort_key=sort_key,
                                           sort_dir=sort_dir)
            if not results:
                break

            for result in results:
                got_ids.append(result['id'])

            # Prevent this running infinitely in error cases
            self.assertTrue(len(got_ids) < (500 + len(expected_ids)))

            marker = results[-1].id

        self.assertEquals(len(got_ids), len(expected_ids))
        self.assertEquals(got_ids, expected_ids)
Beispiel #5
0
 def _get_images(self, context, **params):
     """
     Get images, wrapping in exception if necessary.
     """
     try:
         return db_api.image_get_all(context, **params)
     except exception.NotFound, e:
         msg = _("Invalid marker. Image could not be found.")
         raise exc.HTTPBadRequest(explanation=msg)
Beispiel #6
0
 def _get_images(self, context, **params):
     """
     Get images, wrapping in exception if necessary.
     """
     try:
         return db_api.image_get_all(context, **params)
     except exception.NotFound, e:
         msg = _("Invalid marker. Image could not be found.")
         raise exc.HTTPBadRequest(explanation=msg)
 def test_image_get_all_marker_deleted_showing_deleted_as_admin(self):
     """Specify a deleted image as a marker if showing deleted images."""
     db_api.image_destroy(self.adm_context, UUID1)
     images = db_api.image_get_all(self.adm_context, marker=UUID1)
     self.assertEquals(len(images), 0)
 def test_image_get_all_marker(self):
     images = db_api.image_get_all(self.context, marker=UUID2)
     self.assertEquals(len(images), 1)
 def test_image_get_all(self):
     images = db_api.image_get_all(self.context)
     self.assertEquals(len(images), 2)
Beispiel #10
0
 def test_image_get_all_marker_deleted_showing_deleted_as_admin(self):
     """Specify a deleted image as a marker if showing deleted images."""
     db_api.image_destroy(self.adm_context, UUID1)
     images = db_api.image_get_all(self.adm_context, marker=UUID1)
     self.assertEquals(len(images), 0)
Beispiel #11
0
 def test_image_get_all_marker(self):
     images = db_api.image_get_all(self.context, marker=UUID2)
     self.assertEquals(len(images), 1)
Beispiel #12
0
 def test_image_get_all(self):
     images = db_api.image_get_all(self.context)
     self.assertEquals(len(images), 2)