예제 #1
0
 def test_get_status(self):
     """Test get_status."""
     status = downloadservices.get_status(
         self.user.id, self.volume_id, self.fpath, self.dl_url, self.dl_key)
     self.assertEquals(status, downloadservices.UNKNOWN)
     dl = self.get_or_make_it()
     status = downloadservices.get_status(
         self.user.id, self.volume_id, self.fpath, self.dl_url, self.dl_key)
     self.assertEquals(status, downloadservices.QUEUED)
     # go ahead and complete it and create a file
     mime = u'image/tif'
     hash = get_fake_hash()
     storage_key = uuid.uuid4()
     crc = 12345
     size = deflated_size = 300
     dl = self.get_or_make_it()
     downloadservices.download_complete(
         self.user.id, dl.id, hash, crc, size,
         deflated_size, mime, storage_key)
     status = downloadservices.get_status(
         self.user.id, self.volume_id, self.fpath, self.dl_url, self.dl_key)
     self.assertEquals(status, downloadservices.DOWNLOADED)
     #delete the file
     f = self.user.volume().get_node_by_path(self.fpath)
     f.delete()
     status = downloadservices.get_status(
         self.user.id, self.volume_id, self.fpath, self.dl_url, self.dl_key)
     self.assertEquals(status, downloadservices.DOWNLOADED_NOT_PRESENT)
예제 #2
0
 def test_download_complete(self):
     """Test download_complete."""
     mime = u'image/tif'
     hash = get_fake_hash()
     storage_key = uuid.uuid4()
     crc = 12345
     size = deflated_size = 300
     dl = self.get_or_make_it()
     downloadservices.download_complete(
         self.user.id, dl.id, hash, crc, size,
         deflated_size, mime, storage_key)
     dl = downloadservices.get_download_by_id(self.user.id, dl.id)
     self.assertEquals(dl.status, model.DOWNLOAD_STATUS_COMPLETE)
     f = self.user.volume().get_node_by_path(
         self.fpath, with_content=True)
     self.assertEquals(f.full_path, self.fpath)
     self.assertEquals(f.content_hash, hash)
     self.assertEquals(f.content.storage_key, storage_key)
     self.assertEquals(f.mimetype, mime)