mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-11-22 08:15:13 +00:00
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
24 lines
759 B
Python
24 lines
759 B
Python
# SPDX-License-Identifier: AGPL-3.0-or-later
|
|
"""
|
|
Test module for privileged snapshot operations.
|
|
"""
|
|
|
|
import pathlib
|
|
|
|
import pytest
|
|
|
|
from freedombox.modules.snapshot import privileged
|
|
|
|
systemctl_path = pathlib.Path('/usr/bin/systemctl')
|
|
systemd_installed = pytest.mark.skipif(not systemctl_path.exists(),
|
|
reason='systemd not available')
|
|
|
|
|
|
@pytest.mark.parametrize('input_path,escaped_path',
|
|
[('.snapshots', '\\x2esnapshots'), ('/', '-'),
|
|
('/home/user', 'home-user'), (':_.', ':_.')])
|
|
@systemd_installed
|
|
def test_systemd_path_escape(input_path, escaped_path):
|
|
"""Test escaping systemd paths."""
|
|
assert escaped_path == privileged._systemd_path_escape(input_path)
|