mirror of
https://github.com/d9pouces/id_configurator.git
synced 2026-11-09 01:47:21 +01:00
be91425355
Signed-off-by: d9pouces <github@19pouces.net>
37 lines
917 B
Python
37 lines
917 B
Python
from id_configurator.modules import base as base_module
|
|
from id_configurator.modules.base import (
|
|
Module,
|
|
all_modules,
|
|
register,
|
|
sanitize_filename,
|
|
)
|
|
|
|
|
|
def test_register_and_all_modules_are_isolated(monkeypatch) -> None:
|
|
monkeypatch.setattr(base_module, "_REGISTRY", [])
|
|
|
|
class DummyModule(Module):
|
|
name = "dummy"
|
|
|
|
def is_relevant(self, context) -> bool:
|
|
return True
|
|
|
|
def apply(self, context) -> None:
|
|
pass
|
|
|
|
register(DummyModule)
|
|
|
|
assert all_modules() == [DummyModule]
|
|
|
|
|
|
def test_sanitize_filename_leaves_plain_names_untouched() -> None:
|
|
assert sanitize_filename("interdiode") == "interdiode"
|
|
|
|
|
|
def test_sanitize_filename_replaces_forward_slash() -> None:
|
|
assert sanitize_filename("../../etc/passwd") == ".._.._etc_passwd"
|
|
|
|
|
|
def test_sanitize_filename_replaces_backslash() -> None:
|
|
assert sanitize_filename(r"a\b") == "a_b"
|