Ejemplo n.º 1
0
    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 "
Ejemplo n.º 2
0
 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"
Ejemplo n.º 3
0
 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"
Ejemplo n.º 4
0
 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"
Ejemplo n.º 5
0
 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"
Ejemplo n.º 6
0
 def test_init(self, size):
     FileStorage(size)
Ejemplo n.º 7
0
 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()
Ejemplo n.º 8
0
 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)
Ejemplo n.º 9
0
 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
Ejemplo n.º 10
0
 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
Ejemplo n.º 11
0
 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)
Ejemplo n.º 12
0
 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())
Ejemplo n.º 13
0
 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)