class RetrieveTestsWithPublicBucket(BaseTestMixin, TestCase): def setUp(self): self.media_storage = MinioMediaStorage() self.static_storage = MinioStaticStorage() self.new_file = self.media_storage.save("test-file", ContentFile(b"yep")) self.media_storage.client.set_bucket_policy( self.media_storage.bucket_name, self.media_storage._policy("READ_WRITE")) self.static_storage.client.set_bucket_policy( self.static_storage.bucket_name, self.static_storage._policy("READ_WRITE")) def test_public_url_generation(self): media_test_file_name = self.media_storage.save( u"weird & ÜRΛ", ContentFile(b"irrelevant")) url = self.media_storage.url(media_test_file_name) res = requests.get(url) self.assertEqual(res.content, b"irrelevant") static_test_file_name = self.static_storage.save( u"weird & ÜRΛ", ContentFile(b"irrelevant")) url = self.static_storage.url(static_test_file_name) res = requests.get(url) self.assertEqual(res.content, b"irrelevant")
class RetrieveTestsWithPublicBucket(BaseTestMixin, TestCase): def setUp(self): self.media_storage = MinioMediaStorage() self.static_storage = MinioStaticStorage() self.new_file = self.media_storage.save("test-file", ContentFile(b"yep")) self.media_storage.client.set_bucket_policy( self.media_storage.bucket_name, self.media_storage._policy("READ_WRITE") ) self.static_storage.client.set_bucket_policy( self.static_storage.bucket_name, self.static_storage._policy("READ_WRITE") ) def test_public_url_generation(self): media_test_file_name = self.media_storage.save( u"weird & ÜRΛ", ContentFile(b"irrelevant")) url = self.media_storage.url(media_test_file_name) res = requests.get(url) self.assertEqual(res.content, b"irrelevant") static_test_file_name = self.static_storage.save( u"weird & ÜRΛ", ContentFile(b"irrelevant")) url = self.static_storage.url(static_test_file_name) res = requests.get(url) self.assertEqual(res.content, b"irrelevant")
def setUp(self): self.media_storage = MinioMediaStorage() self.static_storage = MinioStaticStorage() self.new_file = self.media_storage.save("test-file", ContentFile(b"yep")) self.media_storage.client.set_bucket_policy( self.media_storage.bucket_name, '', Policy.READ_WRITE) self.static_storage.client.set_bucket_policy( self.static_storage.bucket_name, '', Policy.READ_WRITE)
def test_public_url_generation(self): media_storage = MinioMediaStorage() media_test_file_name = media_storage.save("weird & ÜRΛ", ContentFile(b"irrelevant")) url = media_storage.url(media_test_file_name) res = requests.get(url) self.assertEqual(res.content, b"irrelevant") static_storage = MinioStaticStorage() static_test_file_name = static_storage.save("weird & ÜRΛ", ContentFile(b"irrelevant")) url = static_storage.url(static_test_file_name) res = requests.get(url) self.assertEqual(res.content, b"irrelevant")
def setUp(self): self.media_storage = MinioMediaStorage() self.static_storage = MinioStaticStorage() self.new_file = self.media_storage.save("test-file", ContentFile(b"yep")) self.second_file = self.media_storage.save("test-file", ContentFile(b"nope"))
def test_static_storage_ignore_bucket_check(self): try: MinioStaticStorage() except OSError: self.assertTrue(False) else: pass
def setUp(self): self.media_storage = MinioMediaStorage() self.static_storage = MinioStaticStorage() self.new_file = self.media_storage.save("test-file", ContentFile(b"yep")) self.media_storage.client.set_bucket_policy( self.media_storage.bucket_name, self.media_storage._policy("READ_WRITE") ) self.static_storage.client.set_bucket_policy( self.static_storage.bucket_name, self.static_storage._policy("READ_WRITE") )
def test_static_storage_ignore_bucket_check(self): MinioStaticStorage()
def test_static_storage_cannot_be_initialized_without_bucket(self): with self.assertRaises(OSError): MinioStaticStorage()
def setUp(self): self.media_storage = MinioMediaStorage() self.static_storage = MinioStaticStorage() self.new_file = self.media_storage.save("a new & original file", ContentFile(b"yep"))