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