test(services): test derivation of foldermoves

This commit is contained in:
Houkime 2023-04-19 12:12:46 +00:00
parent ba72fadb8d
commit dde86725b9
2 changed files with 17 additions and 1 deletions

View file

@ -24,7 +24,7 @@ class FolderMoveNames(BaseModel):
@staticmethod @staticmethod
def from_owned_path(path: OwnedPath) -> FolderMoveNames: def from_owned_path(path: OwnedPath) -> FolderMoveNames:
return FolderMoveNames( return FolderMoveNames(
name=FolderMoveNames.get_foldername(), name=FolderMoveNames.get_foldername(path.path),
bind_location=path.path, bind_location=path.path,
owner=path.owner, owner=path.owner,
group=path.group, group=path.group,

View file

@ -6,6 +6,7 @@ from pytest import raises
from selfprivacy_api.services.bitwarden import Bitwarden from selfprivacy_api.services.bitwarden import Bitwarden
from selfprivacy_api.services.pleroma import Pleroma from selfprivacy_api.services.pleroma import Pleroma
from selfprivacy_api.services.owned_path import OwnedPath 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.test_service import DummyService
from selfprivacy_api.services.service import Service from selfprivacy_api.services.service import Service
@ -40,3 +41,18 @@ def test_paths_from_owned_paths():
assert Pleroma.get_folders() == [ assert Pleroma.get_folders() == [
ownedpath.path for ownedpath in Pleroma.get_owned_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",
)