def test_write_success(self, size, filename, content): file_storage = FileStorage(size) file = File(filename, content) prev_size = file_storage.get_available_size() res = file_storage.write(file) assert file in file_storage.get_files() \ and file_storage.get_available_size() == prev_size - file.get_size() \ and res \ and file.get_size() <= prev_size or \ not res and file not in file_storage.get_files() \ and file_storage.get_available_size() == prev_size, "Invalid write "
def test_get_available_size_after_any_write(self, size_filename_content_data): (size, filename, content) = size_filename_content_data file_storage = FileStorage(size) file = File(filename, content) file_storage.write(file) assert file_storage.get_available_size() == file_storage.get_max_size() - file.get_size(), \ "Invalid get_available_size"
def test_get_max_size_before_any_write(self, storage_size_data): (size) = storage_size_data file_storage = FileStorage(size) assert file_storage.get_max_size() == size, "Invalid get_max_size"
def test_get_files_after_any_write(self, size_filename_content_data): (size, filename, content) = size_filename_content_data file_storage = FileStorage(size) file = File(filename, content) file_storage.write(file) assert file in file_storage.get_files(), "Invalid get_files"
def test_get_files_before_any_write(self, storage_size_data): (size) = storage_size_data file_storage = FileStorage(size) assert file_storage.get_files() == [], "Invalid get_files"
def test_init(self, size): FileStorage(size)
def test_delete_success(self, size_filename_content_data): (size, filename, content) = size_filename_content_data file_storage = FileStorage(size) file = File(filename, content) file_storage.write(file) assert file_storage.delete(file.get_filename()) and file not in file_storage.get_files()
def test_delete_failed(self, size_filename_content_data): (size, filename, content) = size_filename_content_data file_storage = FileStorage(size) assert not file_storage.delete(filename)
def test_get_file_return_none(self, size_and_filename_data): (size, filename) = size_and_filename_data file_storage = FileStorage(size) assert file_storage.get_file(filename) is None
def test_get_file_return_file(self, size_filename_content_data): (size, filename, content) = size_filename_content_data file_storage = FileStorage(size) file = File(filename, content) file_storage.write(file) assert file_storage.get_file(file.get_filename()) == file
def test_is_exists_return_false(self, size_and_filename_data): (size, filename) = size_and_filename_data file_storage = FileStorage(size) assert not file_storage.is_exists(filename)
def test_is_exists_return_true(self, size_filename_content_data): (size, filename, content) = size_filename_content_data file_storage = FileStorage(size) file = File(filename, content) file_storage.write(file) assert file_storage.is_exists(file.get_filename())
def test_write_with_existing_file(self, size_filename_content_data): (size, filename, content) = size_filename_content_data file_storage = FileStorage(size) file = File(filename, content) file_storage.write(file) file_storage.write(file)