Beispiel #1
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"
Beispiel #2
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 "
Beispiel #3
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"
Beispiel #4
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()
Beispiel #5
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())
Beispiel #6
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
 def test_print_text(self, filename, content, capsys):
     file = File(filename, content)
     file.print_text()
     captured = capsys.readouterr()
     assert captured.out == content + "\n", "Not expected print result"
Beispiel #8
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)
 def test_get_filename(self, filename, content):
     file = File(filename, content)
     assert file.get_filename() == filename, "Invalid get_extension"
 def test_get_content(self, filename, content):
     file = File(filename, content)
     assert file.get_content() == content, "Invalid get_content"
 def test_get_size(self, filename, content, exp_size):
     file = File(filename, content)
     assert file.get_size() == exp_size, "Invalid get_size"
 def test_get_extension(self, filename, content, exp_ext):
     file = File(filename, content)
     assert file.get_extension() == exp_ext, "Invalid get_extension"
 def test_init_valid_params(self, filename, content):
     """Validation for Windows"""
     File(filename, content)