예제 #1
0
 def test_read_returns_file_contents(self):
     storage = MockStorage('uploads')
     storage.save('key', '123123')
     file_ = storage.open('key')
     assert file_.read() == '123123'
예제 #2
0
 def test_open_raises_excetion_for_unknown_file(self):
     storage = MockStorage()
     with raises(FileNotFoundError):
         storage.open('key')
예제 #3
0
 def test_size_returns_the_associated_file_size(self):
     storage = MockStorage('uploads')
     storage.save('key', '123123')
     file_ = storage.open('key')
     assert file_.size == 6
예제 #4
0
 def test_supports_directories_in_file_names(self):
     storage = MockStorage()
     storage.save('some_dir/filename.txt', 'something')
     assert storage.open('some_dir/filename.txt').read() == 'something'
예제 #5
0
 def test_open_returns_file_object(self):
     storage = MockStorage()
     storage.save('key', '')
     file_ = storage.open('key')
     assert isinstance(file_, MockStorageFile)
예제 #6
0
 def test_read_returns_file_contents(self):
     storage = MockStorage('uploads')
     storage.save('key', '123123')
     file_ = storage.open('key')
     assert file_.read() == '123123'
예제 #7
0
 def test_reads_file_object_and_saves_in_dict(self):
     storage = MockStorage()
     io = StringIO()
     io.write('file contents')
     storage.save('key', io)
     assert storage.open('key').read() == 'file contents'
예제 #8
0
 def test_size_returns_the_associated_file_size(self):
     storage = MockStorage('uploads')
     storage.save('key', '123123')
     file_ = storage.open('key')
     assert file_.size == 6
예제 #9
0
 def test_open_raises_excetion_for_unknown_file(self):
     storage = MockStorage()
     with raises(FileNotFoundError):
         storage.open('key')
예제 #10
0
 def test_open_returns_file_object(self):
     storage = MockStorage()
     storage.save('key', '')
     file_ = storage.open('key')
     assert isinstance(file_, MockStorageFile)
예제 #11
0
 def test_supports_directories_in_file_names(self):
     storage = MockStorage()
     storage.save('some_dir/filename.txt', 'something')
     assert storage.open('some_dir/filename.txt').read() == 'something'
예제 #12
0
 def test_reads_file_object_and_saves_in_dict(self):
     storage = MockStorage()
     io = StringIO()
     io.write('file contents')
     storage.save('key', io)
     assert storage.open('key').read() == 'file contents'