Skip to content

Commit

Permalink
Probably fixes #28 by passing filename, content to storage save
Browse files Browse the repository at this point in the history
  • Loading branch information
ashwoods committed Aug 11, 2017
1 parent 8f552d4 commit b6592cc
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions tests/test_storages.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ def test_storage_simple_save(self):
field = models.TestModel._meta.get_field('testfile')
field.storage = storage

obj = models.TestModel(testfile=File(self.test_file))
obj = models.TestModel()
obj.testfile.save(self.test_file_name, File(self.test_file))
obj.save()

self.assertTrue(path.isfile(path.join(self.local_dir, obj.testfile.name)))
Expand All @@ -113,9 +114,11 @@ def test_storage_celery_save(self):
field = models.TestModel._meta.get_field('testfile')
field.storage = storage

obj = models.TestModel(testfile=File(self.test_file))
obj = models.TestModel()
obj.testfile.save(self.test_file_name, File(self.test_file))
obj.save()


self.assertTrue(obj.testfile.storage.result.get())
self.assertTrue(path.isfile(path.join(self.local_dir, obj.testfile.name)))
self.assertTrue(
Expand Down Expand Up @@ -165,7 +168,8 @@ def test_transfer_and_delete(self):
field = models.TestModel._meta.get_field('testfile')
field.storage = storage

obj = models.TestModel(testfile=File(self.test_file))
obj = models.TestModel()
obj.testfile.save(self.test_file_name, File(self.test_file))
obj.save()

obj.testfile.storage.result.get()
Expand All @@ -192,7 +196,8 @@ def test_transfer_returns_boolean(self):
field = models.TestModel._meta.get_field('testfile')
field.storage = storage

obj = models.TestModel(testfile=File(self.test_file))
obj = models.TestModel()
obj.testfile.save(self.test_file_name, File(self.test_file))
obj.save()

self.assertRaises(ValueError,
Expand All @@ -213,7 +218,8 @@ def test_transfer_retried(self):

self.assertFalse(models.TestModel.retried)

obj = models.TestModel(testfile=File(self.test_file))
obj = models.TestModel()
obj.testfile.save(self.test_file_name, File(self.test_file))
obj.save()

self.assertFalse(obj.testfile.storage.result.get())
Expand All @@ -230,7 +236,8 @@ def test_delayed_storage(self):
field = models.TestModel._meta.get_field('testfile')
field.storage = storage

obj = models.TestModel(testfile=File(self.test_file))
obj = models.TestModel()
obj.testfile.save(self.test_file_name, File(self.test_file))
obj.save()

self.assertIsNone(getattr(obj.testfile.storage, 'result', None))
Expand All @@ -257,7 +264,8 @@ def test_remote_file_field(self):
field = models.TestModel._meta.get_field('remote')
field.storage = storage

obj = models.TestModel(remote=File(self.test_file))
obj = models.TestModel()
obj.testfile.save(self.test_file_name, File(self.test_file))
obj.save()

self.assertIsNone(getattr(obj.testfile.storage, 'result', None))
Expand Down

0 comments on commit b6592cc

Please sign in to comment.