Skip to content

Commit fba1b71

Browse files
Create test_cli.py
1 parent 945d146 commit fba1b71

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

tests/test_cli.py

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
"""Tests for the command-line interface."""
2+
3+
import pytest
4+
from pathlib import Path
5+
from vyper_sphinx_docs.cli import main
6+
7+
8+
def test_cli_basic(contracts_dir, output_dir, monkeypatch, capsys):
9+
"""Test basic CLI functionality."""
10+
# Mock sys.argv
11+
monkeypatch.setattr('sys.argv', [
12+
'vyper-docs',
13+
str(contracts_dir),
14+
'--output',
15+
str(output_dir)
16+
])
17+
18+
# Run CLI
19+
main()
20+
21+
# Check output
22+
captured = capsys.readouterr()
23+
assert "Documentation built successfully" in captured.out
24+
25+
# Check generated files
26+
docs_dir = output_dir / "docs"
27+
build_dir = docs_dir / "_build"
28+
assert docs_dir.exists()
29+
assert build_dir.exists()
30+
assert (build_dir / "html" / "index.html").exists()
31+
32+
33+
def test_cli_invalid_contracts_dir(tmp_path, monkeypatch, capsys):
34+
"""Test CLI with invalid contracts directory."""
35+
invalid_dir = tmp_path / "nonexistent"
36+
37+
# Mock sys.argv
38+
monkeypatch.setattr('sys.argv', [
39+
'vyper-docs',
40+
str(invalid_dir)
41+
])
42+
43+
# Run CLI and check for error
44+
with pytest.raises(FileNotFoundError):
45+
main()

0 commit comments

Comments
 (0)