Hugoifier

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

Keyboard Shortcuts

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