1 parent
278d3e937e
commit
7bf04ff064
2 files changed
+113
-2
No files matched your search
@@ -0,0 +1,36 @@
|
||||
import subprocess
|
||||
import yaml
|
||||
|
||||
|
||||
def test_init_creates_site(tmp_path):
|
||||
site_dir = tmp_path / "newsite"
|
||||
result = subprocess.run(
|
||||
["ossg", "--site", str(site_dir), "init"],
|
||||
input="My Site\nhttps://example.com\n\n\n",
|
||||
capture_output=True,
|
||||
text=True,
|
||||
)
|
||||
assert result.returncode == 0, result.stderr
|
||||
|
||||
config = yaml.safe_load((site_dir / "config.yml").read_text())
|
||||
assert config == {
|
||||
"name": "My Site",
|
||||
"base_url": "https://example.com/",
|
||||
"template": "plain",
|
||||
"items_per_page": 20,
|
||||
}
|
||||
assert (site_dir / "content").is_dir()
|
||||
|
||||
|
||||
def test_init_refuses_non_empty_dir(tmp_path):
|
||||
(tmp_path / "some_file").touch()
|
||||
|
||||
result = subprocess.run(
|
||||
["ossg", "--site", str(tmp_path), "init"],
|
||||
input="My Site\n\n\n\n",
|
||||
capture_output=True,
|
||||
text=True,
|
||||
)
|
||||
|
||||
assert result.returncode == 1
|
||||
assert "is not empty" in result.stdout
|
||||
Reference in new issue
Block a user