コード例 #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
コード例 #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
コード例 #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
コード例 #4
0
 def test_supports_last_modified(self):
     file_ = MockStorageFile(self.storage, prefix=u'pics/')
     file_.name = 'some_key'
     file_.last_modified
コード例 #5
0
 def test_supports_prefixes(self):
     file_ = MockStorageFile(self.storage, prefix='pics/')
     file_.name = 'some_key'
     assert file_.name == 'pics/some_key'
コード例 #6
0
 def test_supports_save(self):
     file_ = MockStorageFile(self.storage)
     file_.name = 'some_key'
     file_.save(content='something')
     assert file_.read() == 'something'
コード例 #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'
コード例 #8
0
 def test_supports_name_attribute(self):
     storage = MockStorage('uploads')
     file_ = MockStorageFile(storage)
     file_.name = 'some_key'
     assert file_.name == 'some_key'
コード例 #9
0
 def test_supports_file_objects_without_name(self):
     storage = MockStorage('uploads')
     file_ = MockStorageFile(storage)
     assert bool(file_) is False
コード例 #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
コード例 #11
0
 def test_supports_last_modified(self):
     file_ = MockStorageFile(self.storage, prefix=u'pics/')
     file_.name = 'some_key'
     file_.last_modified
コード例 #12
0
 def test_supports_prefixes(self):
     file_ = MockStorageFile(self.storage, prefix='pics/')
     file_.name = 'some_key'
     assert file_.name == 'pics/some_key'
コード例 #13
0
 def test_supports_save(self):
     file_ = MockStorageFile(self.storage)
     file_.name = 'some_key'
     file_.save(content='something')
     assert file_.read() == 'something'
コード例 #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'
コード例 #15
0
 def test_supports_name_attribute(self):
     storage = MockStorage('uploads')
     file_ = MockStorageFile(storage)
     file_.name = 'some_key'
     assert file_.name == 'some_key'