Example #1
0
 def testSettingsOverwritenBySuffixedSettings(self):
     self.assertEqual(StaticS3Storage().settings.AWS_S3_CONTENT_LANGUAGE,
                      "")
     with self.settings(AWS_S3_CONTENT_LANGUAGE="foo",
                        AWS_S3_CONTENT_LANGUAGE_STATIC="bar"):
         self.assertEqual(
             StaticS3Storage().settings.AWS_S3_CONTENT_LANGUAGE, "bar")
Example #2
0
 def setUpClass(cls):
     super(TestS3Storage, cls).setUpClass()
     cls.key_prefix = uuid.uuid4().hex
     cls.storage = S3Storage(aws_s3_key_prefix=cls.key_prefix)
     cls.storage_metadata = S3Storage(
         aws_s3_key_prefix=cls.key_prefix,
         aws_s3_metadata={
             "Content-Disposition":
             lambda name: "attachment;filename={}".format(
                 posixpath.basename(name)),
             "Content-Language":
             "fr",
         })
     cls.insecure_storage = S3Storage(aws_s3_key_prefix=cls.key_prefix,
                                      aws_s3_bucket_auth=False,
                                      aws_s3_max_age_seconds=60 * 60 * 24 *
                                      365)
     cls.key_prefix_static = uuid.uuid4().hex
     cls.static_storage = StaticS3Storage(
         aws_s3_key_prefix=cls.key_prefix_static)
     cls.upload_base = uuid.uuid4().hex
     cls.file_contents = force_bytes(uuid.uuid4().hex * 1000, "ascii")
     cls.file = ContentFile(cls.file_contents)
     cls.upload_dirname = uuid.uuid4().hex
     cls.upload_dir = posixpath.join(cls.upload_base, cls.upload_dirname)
     cls.upload_basename = cls.generateUploadBasename()
     cls.upload_path = cls.generateUploadPath(cls.upload_basename)
     cls.upload_time = datetime.datetime.now()
     # Save a file to the upload path.
     cls.saveTestFile()