Hugoifier

hugoifier / tests / test_generate_decap_config.py
Source Blame History 41 lines
6272677… lmata 1 """Tests for utils.generate_decap_config (thin wrapper around decapify)."""
48176db… ragelink 2 import os
6272677… lmata 3 import tempfile
6272677… lmata 4 import unittest
6272677… lmata 5
91515c0… lmata 6 from hugoifier.utils.generate_decap_config import generate_decap_config
6272677… lmata 7
48176db… ragelink 8
48176db… ragelink 9 class TestGenerateDecapConfig(unittest.TestCase):
6272677… lmata 10 def test_creates_admin_directory(self):
6272677… lmata 11 with tempfile.TemporaryDirectory() as tmp:
6272677… lmata 12 generate_decap_config(tmp)
6272677… lmata 13 self.assertTrue(os.path.isdir(os.path.join(tmp, "static", "admin")))
6272677… lmata 14
6272677… lmata 15 def test_creates_index_html(self):
6272677… lmata 16 with tempfile.TemporaryDirectory() as tmp:
6272677… lmata 17 generate_decap_config(tmp)
6272677… lmata 18 self.assertTrue(os.path.exists(os.path.join(tmp, "static", "admin", "index.html")))
6272677… lmata 19
6272677… lmata 20 def test_creates_config_yml(self):
6272677… lmata 21 with tempfile.TemporaryDirectory() as tmp:
6272677… lmata 22 generate_decap_config(tmp)
6272677… lmata 23 self.assertTrue(os.path.exists(os.path.join(tmp, "static", "admin", "config.yml")))
6272677… lmata 24
6272677… lmata 25 def test_returns_status_string(self):
6272677… lmata 26 with tempfile.TemporaryDirectory() as tmp:
6272677… lmata 27 result = generate_decap_config(tmp)
6272677… lmata 28 self.assertIsInstance(result, str)
6272677… lmata 29 self.assertIn("complete", result.lower())
6272677… lmata 30
6272677… lmata 31 def test_config_yml_has_backend(self):
6272677… lmata 32 with tempfile.TemporaryDirectory() as tmp:
6272677… lmata 33 generate_decap_config(tmp)
6272677… lmata 34 with open(os.path.join(tmp, "static", "admin", "config.yml")) as f:
6272677… lmata 35 content = f.read()
6272677… lmata 36 self.assertIn("backend", content)
218ace3… lmata 37 self.assertIn("github", content)
6272677… lmata 38
6272677… lmata 39
6272677… lmata 40 if __name__ == "__main__":
6272677… lmata 41 unittest.main()

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button