123456789101112131415161718192021222324252627 |
- import json
- import os
- import shutil
- import tempfile
-
- import pytest
-
- from yird.settings import Settings
-
-
- def test_missing_yird_path():
- os.environ["YIRD_PATH"] = ""
- os.environ.pop("YIRD_PATH")
- with pytest.raises(KeyError):
- Settings()
-
-
- def test_reading_yird_path():
- root = tempfile.mkdtemp()
- os.environ["YIRD_PATH"] = root
- with open(os.path.join(root, "settings.json"), "w") as f:
- f.write(json.dumps({
- "PUBLIC_PATH": os.path.join(root, "public"),
- "SITE_NAME": "test website"
- }))
- assert Settings().YIRD_PATH == root
- shutil.rmtree(root)
|