This repository was archived by the owner on Apr 26, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprompt_test.py
More file actions
46 lines (33 loc) · 1.37 KB
/
prompt_test.py
File metadata and controls
46 lines (33 loc) · 1.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import pytest
import git_draft.prompt as sut
from git_draft.worktrees import GitWorktree
class TestCheckPublicTemplateName:
@pytest.mark.parametrize("name", ["ok", ".hidden", "composite-name"])
def test_ok(self, name: str) -> None:
sut._check_public_template_name(name)
@pytest.mark.parametrize("name", ["", "ABC", ".PROMPT", ".with.ext"])
def test_raises(self, name: str) -> None:
with pytest.raises(ValueError):
sut._check_public_template_name(name)
class TestTemplatedPrompt:
@pytest.fixture(autouse=True)
def setup(self, repo) -> None:
self._tree = GitWorktree(repo, "HEAD")
def test_ok(self) -> None:
prompt = sut.TemplatedPrompt("add-test", ("--symbol=foo",))
rendered = prompt.render(self._tree)
assert "foo" in rendered
def test_missing_variable(self) -> None:
prompt = sut.TemplatedPrompt("add-test")
with pytest.raises(ValueError):
prompt.render(self._tree)
class TestFindPromptMetadata:
def test_ok(self) -> None:
metadata = sut.find_prompt_metadata("add-test")
assert metadata
assert "symbol" in (metadata.description or "")
def test_missing(self) -> None:
assert sut.find_prompt_metadata("foo") is None
def test_list_templates() -> None:
templates = list(sut.list_templates(include_local=False))
assert templates