Skip to content

Commit 76672cd

Browse files
Merge pull request #32 from kognitos/add-name-to-connect
fix: fixed connect in template book and added tests that run book tests
2 parents 98283ef + 0ec4883 commit 76672cd

2 files changed

Lines changed: 32 additions & 1 deletion

File tree

tests/test_run_tests.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
2+
import subprocess
3+
import pytest
4+
5+
from change_dir import change_dir
6+
from generate_project import generate_project
7+
8+
9+
PROJECT_SLUG = "test_project"
10+
PROJECT_NAME = "Test Project"
11+
12+
13+
def run_tests(project_directory):
14+
with change_dir(project_directory):
15+
install_result = subprocess.run(["poetry", "install"], capture_output=True, text=True)
16+
tests_result = subprocess.run(["poetry", "run", "tests"], capture_output=True, text=True)
17+
18+
return install_result, tests_result
19+
20+
21+
@pytest.mark.parametrize(
22+
"generate_project",
23+
[{"project_slug": PROJECT_SLUG, "project_name": PROJECT_NAME}],
24+
indirect=True,
25+
)
26+
def test_run_tests_passes(generate_project):
27+
install_result, tests_result = run_tests(generate_project)
28+
29+
assert install_result.returncode == 0, "'poetry install' command failed in generated book"
30+
assert tests_result.returncode == 0, f"'poetry run tests' command failed in generated book. Output: \n\n{tests_result.stdout}"
31+

{{cookiecutter.project_folder_name}}/src/{{cookiecutter.project_slug}}/book.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def timeout(self, timeout: float):
6868
raise ValueError("timeout must be positive")
6969
self._timeout = timeout
7070

71-
@connect(noun_phrase="api keys")
71+
@connect(noun_phrase="api keys", name="Api Keys")
7272
def connect(self, api_key: str):
7373
"""
7474
Connects to an API using the provided API key.

0 commit comments

Comments
 (0)