A flat-file CMS written in Python and Flask
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

test_settings.py 614B

123456789101112131415161718192021222324252627
  1. import json
  2. import os
  3. import shutil
  4. import tempfile
  5. import pytest
  6. from yird.settings import Settings
  7. def test_missing_yird_path():
  8. os.environ["YIRD_PATH"] = ""
  9. os.environ.pop("YIRD_PATH")
  10. with pytest.raises(KeyError):
  11. Settings()
  12. def test_reading_yird_path():
  13. root = tempfile.mkdtemp()
  14. os.environ["YIRD_PATH"] = root
  15. with open(os.path.join(root, "settings.json"), "w") as f:
  16. f.write(json.dumps({
  17. "PUBLIC_PATH": os.path.join(root, "public"),
  18. "SITE_NAME": "test website"
  19. }))
  20. assert Settings().YIRD_PATH == root
  21. shutil.rmtree(root)