Exemple #1
0
def init_fs_with_entity(entity_type, drive_name="home", entity_name="test1"):
    fs = FileSystem()

    fs.create_drive(drive_name)
    new_entity = fs.create(entity_type, entity_name, drive_name)

    return fs, new_entity
Exemple #2
0
    def test_drive_cannot_be_moved(self):
        drive_name = "home"

        fs = FileSystem()
        fs.create_drive(drive_name)

        with self.assertRaises(IllegalFileSystemOperationException):
            fs.move(drive_name, f"new_{drive_name}")
Exemple #3
0
    def test_delete_drive(self):
        drive_name = "home"

        fs = FileSystem()
        fs.create_drive(drive_name)

        fs.delete(drive_name)

        self.assertEqual(len(fs._drives), 0)
Exemple #4
0
    def test_cannnot_create_drives_with_same_name(self):
        fs = FileSystem()
        fs.create_drive("home")

        with self.assertRaises(PathAlreadyExistsException):
            fs.create_drive("home")
Exemple #5
0
    def test_create_drive(self):
        fs = FileSystem()
        fs.create_drive("home")

        self.assertEqual(len(fs._drives), 1)
Exemple #6
0
    def test_check_that_file_does_not_exist(self):
        fs = FileSystem()
        fs.create_drive("home")

        self.assertFalse(fs.exists("home\\test1.txt"))
Exemple #7
0
    def test_cannot_create_file_if_parent_does_not_exist(self):
        fs = FileSystem()
        fs.create_drive("home")

        with self.assertRaises(PathNotFoundException):
            fs.create(EntityType.FILE, "file1.txt", "home\\does_not_exist")