mirror of
https://github.com/ycd/manage-fastapi.git
synced 2021-11-08 01:34:39 +03:00
✅ Add tests for docker support
This commit is contained in:
@@ -1,28 +1,44 @@
|
||||
from unittest.mock import patch
|
||||
|
||||
import pytest
|
||||
from manage_fastapi.main import app
|
||||
from typer.testing import CliRunner
|
||||
|
||||
from manage_fastapi.main import app
|
||||
|
||||
runner = CliRunner()
|
||||
|
||||
CREATED_SUCCESSFULLY = "FastAPI project created successfully! 🎉\n"
|
||||
ALREADY_EXISTS = "Folder 'potato' already exists. 😞\n"
|
||||
|
||||
|
||||
@pytest.mark.parametrize("package_", ["pip", "poetry"])
|
||||
@pytest.mark.parametrize("packaging", ["pip", "poetry"])
|
||||
@pytest.mark.parametrize("python", ["3.6", "3.7", "3.8"])
|
||||
@pytest.mark.parametrize(
|
||||
"license_", ["MIT", "BSD-3", "GNU GPL v3.0", "Apache Software License 2.0"]
|
||||
)
|
||||
@pytest.mark.parametrize("pre_commit", [True, False])
|
||||
@pytest.mark.parametrize("docker", [True, False])
|
||||
def test_startproject(
|
||||
project_name: str, package_: str, python: str, license_: str, pre_commit: bool
|
||||
project_name: str,
|
||||
packaging: str,
|
||||
python: str,
|
||||
license_: str,
|
||||
pre_commit: bool,
|
||||
docker: bool,
|
||||
):
|
||||
package = "manage_fastapi.main.launch_cli"
|
||||
with patch(
|
||||
package, return_value=[package_, python, license_, pre_commit]
|
||||
) as mock_obj:
|
||||
with patch(package) as mock_obj:
|
||||
|
||||
def side_effect(*args):
|
||||
return {
|
||||
"packaging": packaging,
|
||||
"python": python,
|
||||
"license": license_,
|
||||
"pre_commit": pre_commit,
|
||||
"docker": docker,
|
||||
}
|
||||
|
||||
mock_obj.side_effect = side_effect
|
||||
result = runner.invoke(app, ["startproject", project_name])
|
||||
assert mock_obj.assert_called_once
|
||||
assert result.output == CREATED_SUCCESSFULLY
|
||||
|
||||
Reference in New Issue
Block a user