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_size(self, filename, content, exp_size):
     file = File(filename, content)
     assert file.get_size() == exp_size, "Invalid get_size"