From dde86725b9feaa184d17d97c47e3ef59608dea89 Mon Sep 17 00:00:00 2001 From: Houkime <> Date: Wed, 19 Apr 2023 12:12:46 +0000 Subject: [PATCH] test(services): test derivation of foldermoves --- .../services/generic_service_mover.py | 2 +- tests/test_services.py | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/selfprivacy_api/services/generic_service_mover.py b/selfprivacy_api/services/generic_service_mover.py index cf353cd..1e5efe6 100644 --- a/selfprivacy_api/services/generic_service_mover.py +++ b/selfprivacy_api/services/generic_service_mover.py @@ -24,7 +24,7 @@ class FolderMoveNames(BaseModel): @staticmethod def from_owned_path(path: OwnedPath) -> FolderMoveNames: return FolderMoveNames( - name=FolderMoveNames.get_foldername(), + name=FolderMoveNames.get_foldername(path.path), bind_location=path.path, owner=path.owner, group=path.group, diff --git a/tests/test_services.py b/tests/test_services.py index fbbae09..5816140 100644 --- a/tests/test_services.py +++ b/tests/test_services.py @@ -6,6 +6,7 @@ from pytest import raises from selfprivacy_api.services.bitwarden import Bitwarden from selfprivacy_api.services.pleroma import Pleroma from selfprivacy_api.services.owned_path import OwnedPath +from selfprivacy_api.services.generic_service_mover import FolderMoveNames from selfprivacy_api.services.test_service import DummyService from selfprivacy_api.services.service import Service @@ -40,3 +41,18 @@ def test_paths_from_owned_paths(): assert Pleroma.get_folders() == [ ownedpath.path for ownedpath in Pleroma.get_owned_folders() ] + + +def test_foldermoves_from_ownedpaths(): + owned = OwnedPath( + path="var/lib/bitwarden", + group="vaultwarden", + owner="vaultwarden", + ) + + assert FolderMoveNames.from_owned_path(owned) == FolderMoveNames( + name="bitwarden", + bind_location="var/lib/bitwarden", + group="vaultwarden", + owner="vaultwarden", + )