Exemple #1
0
 def test_equality_operator(self):
     file_ = MockStorageFile(self.storage)
     file_.name = 'some_key'
     file2 = MockStorageFile(self.storage)
     file2.name = 'some_key'
     assert file_ == file2
     file2.rename('some other key')
     assert file_ != file2
Exemple #2
0
 def test_equality_operator(self):
     file_ = MockStorageFile(self.storage)
     file_.name = 'some_key'
     file2 = MockStorageFile(self.storage)
     file2.name = 'some_key'
     assert file_ == file2
     file2.rename('some other key')
     assert file_ != file2
Exemple #3
0
 def test_equality_operator_with_none_values(self):
     file_ = MockStorageFile(self.storage)
     file_.name = 'some_key'
     none = None
     assert not file_ == none
     assert file_ != none
Exemple #4
0
 def test_supports_last_modified(self):
     file_ = MockStorageFile(self.storage, prefix=u'pics/')
     file_.name = 'some_key'
     file_.last_modified
Exemple #5
0
 def test_supports_prefixes(self):
     file_ = MockStorageFile(self.storage, prefix='pics/')
     file_.name = 'some_key'
     assert file_.name == 'pics/some_key'
Exemple #6
0
 def test_supports_save(self):
     file_ = MockStorageFile(self.storage)
     file_.name = 'some_key'
     file_.save(content='something')
     assert file_.read() == 'something'
Exemple #7
0
 def test_rename_throws_error(self):
     storage = MockStorage('uploads')
     file_ = MockStorageFile(storage)
     file_.name = 'some_key'
     with raises(StorageException):
         file_.name = 'some_key2'
Exemple #8
0
 def test_supports_name_attribute(self):
     storage = MockStorage('uploads')
     file_ = MockStorageFile(storage)
     file_.name = 'some_key'
     assert file_.name == 'some_key'
Exemple #9
0
 def test_supports_file_objects_without_name(self):
     storage = MockStorage('uploads')
     file_ = MockStorageFile(storage)
     assert bool(file_) is False
Exemple #10
0
 def test_equality_operator_with_none_values(self):
     file_ = MockStorageFile(self.storage)
     file_.name = 'some_key'
     none = None
     assert not file_ == none
     assert file_ != none
Exemple #11
0
 def test_supports_last_modified(self):
     file_ = MockStorageFile(self.storage, prefix=u'pics/')
     file_.name = 'some_key'
     file_.last_modified
Exemple #12
0
 def test_supports_prefixes(self):
     file_ = MockStorageFile(self.storage, prefix='pics/')
     file_.name = 'some_key'
     assert file_.name == 'pics/some_key'
Exemple #13
0
 def test_supports_save(self):
     file_ = MockStorageFile(self.storage)
     file_.name = 'some_key'
     file_.save(content='something')
     assert file_.read() == 'something'
Exemple #14
0
 def test_rename_throws_error(self):
     storage = MockStorage('uploads')
     file_ = MockStorageFile(storage)
     file_.name = 'some_key'
     with raises(StorageException):
         file_.name = 'some_key2'
Exemple #15
0
 def test_supports_name_attribute(self):
     storage = MockStorage('uploads')
     file_ = MockStorageFile(storage)
     file_.name = 'some_key'
     assert file_.name == 'some_key'