Exemple #1
0
 def test_fullpath_multiple_sources_new_file_uses_most_free_space_source(
         self, fs, monkeypatch):
     monkeypatch.setattr(Filesystem, "_get_free_blocks", {
         "/disk0": 50,
         "/disk1": 100
     }.get)
     fs.add_mount_point("/disk0", 50)
     fs.add_mount_point("/disk1", 100)
     cfs = Filesystem(["/disk0", "/disk1"], "/cfsroot")
     assert cfs._full_path("/test") == "/disk1/test"
Exemple #2
0
 def test_fullpath_multiple_empty_sources_new_dir_uses_first_source(
         self, fs, monkeypatch):
     monkeypatch.setattr(Filesystem, "_get_free_blocks", {
         "/disk0": 50,
         "/disk1": 50
     }.get)
     fs.add_mount_point("/disk0")
     fs.add_mount_point("/disk1")
     cfs = Filesystem(["/disk0", "/disk1"], "/cfsroot")
     assert cfs._full_path("/dir/") == "/disk0/dir/"
Exemple #3
0
 def test_fullpath_multiple_empty_sources_new_file_in_subdirectory_uses_the_existing_base_directory_source(
         self, fs, monkeypatch):
     # disk1 has more free space, but prefer the existing base dir on disk0
     monkeypatch.setattr(Filesystem, "_get_free_blocks", {
         "/disk0": 50,
         "/disk1": 100
     }.get)
     fs.add_mount_point("/disk0", 50)
     fs.add_mount_point("/disk1", 100)
     fs.create_dir("/disk0/basedir/dir")
     cfs = Filesystem(["/disk0", "/disk1"], "/cfsroot")
     assert cfs._full_path("/basedir/dir/test") == "/disk0/basedir/dir/test"
Exemple #4
0
 def test_constructor_dir_collision_fails(self, fs):
     fs.add_mount_point("/disk0")
     fs.add_mount_point("/disk1")
     fs.create_dir("/disk0/dir")
     fs.create_dir("/disk1/dir")
     with pytest.raises(DuplicatePathException):
         assert Filesystem(["/disk0", "/disk1"], "/cfsroot")
Exemple #5
0
 def test_constructor_no_collisions_succeeds(self, fs):
     fs.add_mount_point("/disk0")
     fs.add_mount_point("/disk1")
     fs.create_file("/disk0/dir0/test")
     fs.create_file("/disk1/dir1/test")
     Filesystem(["/disk0", "/disk1"], "/cfsroot")
     pass  # no exception
Exemple #6
0
 def test_constructor_empty_filesystem_succeeds(self, fs):
     fs.add_mount_point("/disk0")
     fs.add_mount_point("/disk1")
     Filesystem(["/disk0", "/disk1"], "/cfsroot")
     pass  # no exception
Exemple #7
0
 def test_fullpath_single_empty_source_new_dir(self, fs, monkeypatch):
     monkeypatch.setattr(Filesystem, "_get_free_blocks", {"/disk0": 50}.get)
     fs.add_mount_point("/disk0")
     cfs = Filesystem(["/disk0"], "/cfsroot")
     assert cfs._full_path("/dir/") == "/disk0/dir/"
Exemple #8
0
 def test_fullpath_multiple_source_directory_exists_uses_existing_directory(
         self, fs):
     fs.create_dir("/disk0")
     fs.create_dir("/disk1/dir/")
     cfs = Filesystem(["/disk0", "/disk1"], "/cfsroot")
     assert cfs._full_path("/dir/") == "/disk1/dir/"
Exemple #9
0
 def test_fullpath_single_source_directory_exists(self, fs):
     fs.create_dir("/disk0/dir/")
     cfs = Filesystem(["/disk0"], "/cfsroot")
     assert cfs._full_path("/dir/") == "/disk0/dir/"