test: cover chat core and session storage
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
from javis.config.settings import ConfigurationError, Settings, default_data_dir
|
||||
|
||||
|
||||
class SettingsTests(unittest.TestCase):
|
||||
def test_windows_default_uses_local_app_data(self) -> None:
|
||||
result = default_data_dir(
|
||||
{"LOCALAPPDATA": "C:\\Local"},
|
||||
platform_name="nt",
|
||||
home=Path("C:\\Users\\test"),
|
||||
)
|
||||
self.assertEqual(result, Path("C:\\Local") / "Javis")
|
||||
|
||||
def test_posix_default_uses_xdg_data_home(self) -> None:
|
||||
result = default_data_dir(
|
||||
{"XDG_DATA_HOME": "/tmp/data"},
|
||||
platform_name="posix",
|
||||
home=Path("/home/test"),
|
||||
)
|
||||
self.assertEqual(result, Path("/tmp/data/javis"))
|
||||
|
||||
def test_explicit_data_dir_must_be_absolute(self) -> None:
|
||||
with self.assertRaises(ConfigurationError):
|
||||
Settings.from_env({"JAVIS_DATA_DIR": "relative"})
|
||||
|
||||
def test_provider_url_must_remain_local(self) -> None:
|
||||
with self.assertRaises(ConfigurationError):
|
||||
Settings.from_env(
|
||||
{
|
||||
"JAVIS_DATA_DIR": str(Path.cwd()),
|
||||
"JAVIS_OLLAMA_URL": "https://example.com",
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user