def test_file_size(self):
     """
     Verify size is correct after dss put and get
     """
     tempdir = tempfile.gettempdir()
     self._test_file_size(Replica.aws, "s3", self.s3_test_bucket, S3Uploader(tempdir, self.s3_test_bucket))
     self._test_file_size(Replica.gcp, "gs", self.gs_test_bucket, GSUploader(tempdir, self.gs_test_bucket))
Exemple #2
0
 def test_file_put_cached_files_init_into_checkout(self):
     tempdir = tempfile.gettempdir()
     self._test_file_put_cached(Replica.aws, "s3", self.s3_test_bucket,
                                self.s3_test_checkout_bucket,
                                S3Uploader(tempdir, self.s3_test_bucket))
     self._test_file_put_cached(Replica.gcp, "gs", self.gs_test_bucket,
                                self.gs_test_checkout_bucket,
                                GSUploader(tempdir, self.gs_test_bucket))
Exemple #3
0
 def test_file_get_checkout(self):
     """
     Verifies checkout occurs on first get and not on second.
     """
     tempdir = tempfile.gettempdir()
     self._test_file_get_checkout(Replica.aws, "s3", self.s3_test_bucket,
                                  S3Uploader(tempdir, self.s3_test_bucket))
     self._test_file_get_checkout(Replica.gcp, "gs", self.gs_test_bucket,
                                  GSUploader(tempdir, self.gs_test_bucket))
Exemple #4
0
 def test_file_get_invalid_token(self):
     """
     Verifies that a checkout request with a malformed token returns a 400.
     :return:
     """
     tempdir = tempfile.gettempdir()
     self._test_file_get_invalid_token(
         Replica.aws, "s3", self.s3_test_bucket,
         S3Uploader(tempdir, self.s3_test_bucket))
     self._test_file_get_invalid_token(
         Replica.gcp, "gs", self.gs_test_bucket,
         GSUploader(tempdir, self.gs_test_bucket))
Exemple #5
0
    def test_file_put_bad_checksum(self):
        src_key = generate_test_key()
        uploader = S3Uploader(tempfile.gettempdir(), self.s3_test_bucket)
        with tempfile.NamedTemporaryFile(delete=True) as fh:
            fh.write(os.urandom(1024))
            fh.flush()
            uploader.upload_file(fh.name,
                                 src_key,
                                 'text/plain',
                                 metadata_keys=self.bad_checksums)

        source_url = f's3://{self.s3_test_bucket}/{src_key}'
        file_uuid = str(uuid.uuid4())
        bundle_uuid = str(uuid.uuid4())
        version = datetime_to_version_format(datetime.datetime.utcnow())
        # catch AssertionError raised when upload returns 422 instead of 201
        with self.assertRaises(AssertionError):
            r = self.upload_file(source_url,
                                 file_uuid,
                                 bundle_uuid=bundle_uuid,
                                 version=version)
            self.assertEqual(r.json['code'], 'invalid_checksum')
Exemple #6
0
 def test_file_put(self):
     tempdir = tempfile.gettempdir()
     self._test_file_put(Replica.aws, "s3", self.s3_test_bucket,
                         S3Uploader(tempdir, self.s3_test_bucket))
     self._test_file_put(Replica.gcp, "gs", self.gs_test_bucket,
                         GSUploader(tempdir, self.gs_test_bucket))