Exemplo n.º 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.assertEqual(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.assertEqual(status, Download.STATUS_QUEUED)
     # go ahead and complete it and create a file
     mime = 'image/tif'
     hash = self.factory.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.assertEqual(status, Download.STATUS_COMPLETE)
     # 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.assertEqual(status, downloadservices.DOWNLOADED_NOT_PRESENT)
 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.assertEqual(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.assertEqual(status, Download.STATUS_QUEUED)
     # go ahead and complete it and create a file
     mime = 'image/tif'
     hash = self.factory.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.assertEqual(status, Download.STATUS_COMPLETE)
     # 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.assertEqual(status, downloadservices.DOWNLOADED_NOT_PRESENT)
Exemplo n.º 3
0
 def test_download_complete(self):
     """Test download_complete."""
     mime = 'image/tif'
     hash = self.factory.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.assertEqual(dl.status, Download.STATUS_COMPLETE)
     f = self.user.volume().get_node_by_path(self.fpath, with_content=True)
     self.assertEqual(f.full_path, self.fpath)
     self.assertEqual(f.content_hash, hash)
     self.assertEqual(f.content.storage_key, storage_key)
     self.assertEqual(f.mimetype, mime)
 def test_download_complete(self):
     """Test download_complete."""
     mime = 'image/tif'
     hash = self.factory.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.assertEqual(dl.status, Download.STATUS_COMPLETE)
     f = self.user.volume().get_node_by_path(
         self.fpath, with_content=True)
     self.assertEqual(f.full_path, self.fpath)
     self.assertEqual(f.content_hash, hash)
     self.assertEqual(f.content.storage_key, storage_key)
     self.assertEqual(f.mimetype, mime)