Skip to content

Commit 3e67c44

Browse files
committed
update cloner app tests
1 parent 5a90109 commit 3e67c44

File tree

6 files changed

+288
-2696
lines changed

6 files changed

+288
-2696
lines changed

pdm.lock

Lines changed: 170 additions & 2648 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ classifiers = [
2323
requires-python = ">=3.7,<4.0"
2424
dependencies = [
2525
"typer[all]==0.9.0",
26-
"requests==2.25.1",
26+
"requests>=2.31.0",
2727
"questionary==1.10.0",
2828
]
2929

@@ -34,7 +34,6 @@ repository = "https://github.com/wu-clan/fastapi_ccli"
3434
[tool.pdm.dev-dependencies]
3535
test = [
3636
"pytest<8.0,>=7.0",
37-
"keyboard>=0.13.5",
3837
]
3938
lint = [
4039
"pre-commit>=2.21.0",

requirements.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
certifi==2023.7.22
55
cfgv==3.3.1
6-
chardet==4.0.0
6+
charset-normalizer==3.3.1
77
click==8.1.7
88
colorama==0.4.6
99
distlib==0.3.7
@@ -12,7 +12,6 @@ filelock==3.12.2
1212
identify==2.5.24
1313
idna==2.10
1414
iniconfig==2.0.0
15-
keyboard==0.13.5
1615
markdown-it-py==2.2.0
1716
mdurl==0.1.2
1817
nodeenv==1.8.0

tests/test_cloner_en.py

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
#!/usr/bin/env python3
2+
# -*- coding: utf-8 -*-
3+
import pytest
4+
from click import BadParameter, BadOptionUsage
5+
from typer.testing import CliRunner
6+
7+
from fastapi_ccli.cloner.cloner_en import app_en
8+
9+
runner = CliRunner()
10+
11+
12+
def test_en_version():
13+
"""
14+
test cloner en version
15+
"""
16+
result = runner.invoke(app_en, ["--version"])
17+
assert "FastAPI CCLI" in result.output
18+
assert result.exit_code == 0
19+
result = runner.invoke(app_en, ["-V"])
20+
assert "FastAPI CCLI" in result.output
21+
assert result.exit_code == 0
22+
23+
24+
def test_en_orm_sqlalchemy():
25+
"""
26+
test cloner en orm sqlalchemy
27+
"""
28+
result = runner.invoke(app_en, ["--orm", "sqlalchemy"])
29+
assert result.output == ""
30+
assert result.exit_code == 0
31+
32+
33+
def test_en_orm_tortoise():
34+
"""
35+
test cloner en orm tortoise
36+
"""
37+
result = runner.invoke(app_en, ["--orm", "tortoise"])
38+
assert result.output == ""
39+
assert result.exit_code == 0
40+
41+
42+
def test_en_orm_sqlmodel():
43+
"""
44+
test cloner en orm sqlmodel
45+
"""
46+
result = runner.invoke(app_en, ["--orm", "sqlmodel"])
47+
assert result.output == ""
48+
assert result.exit_code == 0
49+
50+
51+
@pytest.mark.skip("Unknown reasons, invoke was unable to catch the exception")
52+
def test_en_orm_illegal_value():
53+
"""
54+
test cloner en orm illegal value
55+
"""
56+
with pytest.raises(BadParameter) as exc_info:
57+
runner.invoke(app_en, ["--orm", "none"], catch_exceptions=False)
58+
assert exc_info.value.exit_code == 2
59+
assert (
60+
exc_info.value.message
61+
== "Invalid value: Enter unknown parameters, only allowed 'sqlalchemy' / 'tortoise' / 'sqlmodel'"
62+
)
63+
64+
65+
@pytest.mark.skip("Unknown reasons, invoke was unable to catch the exception")
66+
def test_en_orm_no_argument():
67+
"""
68+
test cloner en orm no argument
69+
"""
70+
with pytest.raises(BadOptionUsage) as exc_info:
71+
runner.invoke(app_en, ["--orm"], catch_exceptions=False)
72+
assert exc_info.value.exit_code == 2
73+
assert exc_info.value.message == "Option '--orm' requires an argument."
74+
75+
76+
@pytest.mark.skip("Unknown reasons, invoke was unable to catch the exception")
77+
def test_en_project_path():
78+
"""
79+
test cloner en project path
80+
"""
81+
with pytest.raises(BadParameter) as exc_info:
82+
runner.invoke(app_en, ["--path", "100"], catch_exceptions=False)
83+
assert exc_info.value.exit_code == 2
84+
assert exc_info.value.message == "Invalid value: Wrong parameter input, please enter the correct path"

tests/test_cloner_en_form.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/usr/bin/env python3
2+
# -*- coding: utf-8 -*-
3+
import pytest
4+
from click import BadParameter
5+
from typer.testing import CliRunner
6+
7+
from fastapi_ccli.cloner.cloner_en_form import app_en_form
8+
9+
runner = CliRunner()
10+
11+
12+
def test_en_form_version():
13+
"""
14+
test cloner en form version
15+
"""
16+
result = runner.invoke(app_en_form, ["--version"])
17+
assert "FastAPI CCLI" in result.output
18+
assert result.exit_code == 0
19+
result = runner.invoke(app_en_form, ["-V"])
20+
assert "FastAPI CCLI" in result.output
21+
assert result.exit_code == 0
22+
23+
24+
@pytest.mark.skip("Unknown reasons, invoke was unable to catch the exception")
25+
def test_en_form_orm():
26+
"""
27+
test cloner en form orm
28+
"""
29+
with pytest.raises(BadParameter) as exc_info:
30+
runner.invoke(app_en_form, ["--path", "100"], catch_exceptions=False)
31+
assert exc_info.value.exit_code == 2
32+
assert exc_info.value.message == "Invalid value: Wrong parameter input, please enter the correct path"

tests/test_main.py

Lines changed: 0 additions & 44 deletions
This file was deleted.

0 commit comments

Comments
 (0)