def test_get_blobs(self): query = db.Query(model_class=blobstore.BlobInfo, namespace='') query.order('-creation').AndReturn(query) query.fetch(10, offset=40).AndReturn(['some blob']) self.mox.ReplayAll() self.assertEqual(['some blob'], blobstore_viewer._get_blobs(start=40, limit=10)) self.mox.VerifyAll()
def test_get_with_offset(self): request = webapp2.Request.blank('/blobstore?offset=40') response = webapp2.Response() handler = blobstore_viewer.BlobstoreRequestHandler(request, response) blob_infos = [object() for _ in range(10)] blobstore_viewer._get_blobs(40, BLOBS_PER_PAGE+1).AndReturn(blob_infos) handler.render('blobstore_viewer.html', {'previous': 20, 'next': None, 'blob_infos': blob_infos, 'offset': 40, 'return_to': 'http://localhost/blobstore?offset=40', }) self.mox.ReplayAll() handler.get() self.mox.VerifyAll()
def test_get_blobs(self): query = db.Query( model_class=blobstore.BlobInfo, namespace='') query.order('-creation').AndReturn(query) query.fetch(10, offset=40).AndReturn(['some blob']) self.mox.ReplayAll() self.assertEqual(['some blob'], blobstore_viewer._get_blobs(start=40, limit=10)) self.mox.VerifyAll()
def test_get_with_offset(self): request = webapp2.Request.blank('/blobstore?offset=40') response = webapp2.Response() handler = blobstore_viewer.BlobstoreRequestHandler(request, response) blob_infos = [object() for _ in range(10)] blobstore_viewer._get_blobs(40, BLOBS_PER_PAGE + 1).AndReturn(blob_infos) handler.render( 'blobstore_viewer.html', { 'previous': 20, 'next': None, 'blob_infos': blob_infos, 'offset': 40, 'return_to': 'http://localhost/blobstore?offset=40', }) self.mox.ReplayAll() handler.get() self.mox.VerifyAll()
def test_get_with_data_in_next_page(self): request = webapp2.Request.blank('/blobstore') response = webapp2.Response() handler = blobstore_viewer.BlobstoreRequestHandler(request, response) blob_infos = [object() for _ in range(BLOBS_PER_PAGE + 1)] blobstore_viewer._get_blobs(0, BLOBS_PER_PAGE + 1).AndReturn(blob_infos) admin_request_handler.AdminRequestHandler(handler).get() handler.render( 'blobstore_viewer.html', { 'previous': None, 'next': 20, 'blob_infos': blob_infos[:BLOBS_PER_PAGE], 'offset': 0, 'return_to': 'http://localhost/blobstore', }) self.mox.ReplayAll() handler.get() self.mox.VerifyAll()