Grotti 2.10.0: Orca-Senden, Slice-Ordner, ED-Strom, Hygiene.
Slice-Watch mit Ordnern/Filtern, Orca-Nachbearbeitung, Cockpit-Verlauf mit ED, Zeitzone im Browser. Tasten-Grenze und README-API angeglichen, toter Code entfernt, Requirements gepinnt.
This commit is contained in:
1 parent
efd0801cd1
commit
9e22cebb81
48 files changed
+2259
-422
No files matched your search
@@ -0,0 +1,49 @@
|
||||
"""Slice-Ordner (watch_dir) in config."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import tempfile
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
from unittest.mock import patch
|
||||
|
||||
from grotti import config
|
||||
from grotti.errors import GrottiError
|
||||
|
||||
|
||||
class WatchDirTest(unittest.TestCase):
|
||||
def test_empty(self):
|
||||
path, stored = config.parse_watch_dir("")
|
||||
self.assertIsNone(path)
|
||||
self.assertEqual(stored, "")
|
||||
|
||||
def test_relative_under_root(self):
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
root = Path(tmp)
|
||||
target = root / "slice"
|
||||
target.mkdir()
|
||||
with patch.object(config, "ROOT", root):
|
||||
path, stored = config.parse_watch_dir("slice", create=False)
|
||||
self.assertEqual(path, target.resolve())
|
||||
self.assertEqual(stored, "slice")
|
||||
|
||||
def test_create(self):
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
root = Path(tmp)
|
||||
with patch.object(config, "ROOT", root):
|
||||
path, stored = config.parse_watch_dir("slice", create=True)
|
||||
self.assertTrue(path.is_dir())
|
||||
self.assertEqual(stored, "slice")
|
||||
|
||||
def test_file_rejected(self):
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
root = Path(tmp)
|
||||
file_path = root / "not-a-dir"
|
||||
file_path.write_text("x", encoding="utf-8")
|
||||
with patch.object(config, "ROOT", root):
|
||||
with self.assertRaises(GrottiError):
|
||||
config.parse_watch_dir(str(file_path), create=False)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in new issue
Block a user