|
1 |
| -from pathlib import Path |
2 |
| - |
3 | 1 | import pytest
|
4 | 2 | from cappa.testing import CommandRunner
|
5 |
| -from falco_cli.config import read_falco_config |
6 |
| - |
7 |
| - |
8 |
| -def all_files_are_correctly_generated(project_name, project_dir: Path) -> bool: |
9 |
| - required_files = [ |
10 |
| - "pyproject.toml", |
11 |
| - "README.md", |
12 |
| - ".gitignore", |
13 |
| - ".github", |
14 |
| - "deploy", |
15 |
| - "tests", |
16 |
| - "manage.py", |
17 |
| - ".env.template", |
18 |
| - "docs", |
19 |
| - "docs/conf.py", |
20 |
| - f"{project_name}/settings.py", |
21 |
| - f"{project_name}/urls.py", |
22 |
| - f"{project_name}/wsgi.py", |
23 |
| - ] |
24 |
| - return all((project_dir / file).exists() for file in required_files) |
25 |
| - |
26 |
| - |
27 |
| -@pytest.mark.parametrize( |
28 |
| - "blueprint_path", |
29 |
| - [ |
30 |
| - Path("blueprints/tailwind").resolve(strict=True), |
31 |
| - Path("blueprints/bootstrap").resolve(strict=True), |
32 |
| - ], |
33 |
| -) |
34 |
| -def test_start_project(blueprint_path, runner: CommandRunner): |
35 |
| - runner.invoke( |
36 |
| - "start-project", |
37 |
| - "dotfm", |
38 |
| - "--skip-new-version-check", |
39 |
| - "--blueprint", |
40 |
| - str(blueprint_path), |
41 |
| - ) |
42 |
| - assert Path("dotfm").exists() |
43 |
| - config = read_falco_config(Path("dotfm/pyproject.toml")) |
44 |
| - config_keys = config.keys() |
45 |
| - assert "blueprint" in config_keys |
46 |
| - assert "revision" in config_keys |
47 |
| - assert "work" in config_keys |
48 |
| - |
49 |
| - assert all_files_are_correctly_generated("dotfm", project_dir=Path("dotfm")) |
50 | 3 |
|
51 | 4 |
|
52 |
| -# def test_start_project_alias_name(runner: CommandRunner): |
| 5 | +@pytest.mark.parametrize("blueprint", ["tailwind", "bootstrap"]) |
| 6 | +def test_start_project(tmp_path, blueprint: str, runner: CommandRunner): |
| 7 | + runner.invoke("start-project", "dotfm", "--blueprint", blueprint) |
| 8 | + assert (tmp_path / "dotfm").exists() |
| 9 | + assert (tmp_path / "dotfm/dotfm/settings.py").exists() |
| 10 | + assert (tmp_path / "dotfm/dotfm/urls.py").exists() |
| 11 | + assert (tmp_path / "dotfm/dotfm/wsgi.py").exists() |
| 12 | + |
| 13 | +# def all_files_are_correctly_generated(project_name, project_dir: Path) -> bool: |
| 14 | +# required_files = [ |
| 15 | +# "pyproject.toml", |
| 16 | +# "README.md", |
| 17 | +# ".gitignore", |
| 18 | +# ".github", |
| 19 | +# "deploy", |
| 20 | +# "tests", |
| 21 | +# "manage.py", |
| 22 | +# ".env.template", |
| 23 | +# "docs", |
| 24 | +# "docs/conf.py", |
| 25 | +# f"{project_name}/settings.py", |
| 26 | +# f"{project_name}/urls.py", |
| 27 | +# f"{project_name}/wsgi.py", |
| 28 | +# ] |
| 29 | +# return all((project_dir / file).exists() for file in required_files) |
| 30 | +# |
| 31 | +# |
| 32 | +# @pytest.mark.parametrize( |
| 33 | +# "blueprint_path", |
| 34 | +# [ |
| 35 | +# Path("blueprints/tailwind").resolve(strict=True), |
| 36 | +# Path("blueprints/bootstrap").resolve(strict=True), |
| 37 | +# ], |
| 38 | +# ) |
| 39 | +# def test_start_project(blueprint_path, runner: CommandRunner): |
53 | 40 | # runner.invoke(
|
54 | 41 | # "start-project",
|
55 | 42 | # "dotfm",
|
56 | 43 | # "--skip-new-version-check",
|
57 | 44 | # "--blueprint",
|
58 |
| -# "tailwind", |
| 45 | +# str(blueprint_path), |
59 | 46 | # )
|
60 | 47 | # assert Path("dotfm").exists()
|
61 | 48 | # config = read_falco_config(Path("dotfm/pyproject.toml"))
|
62 | 49 | # config_keys = config.keys()
|
63 | 50 | # assert "blueprint" in config_keys
|
64 | 51 | # assert "revision" in config_keys
|
65 | 52 | # assert "work" in config_keys
|
66 |
| -# assert len(config["revision"]) > 10 |
67 | 53 | #
|
68 | 54 | # assert all_files_are_correctly_generated("dotfm", project_dir=Path("dotfm"))
|
69 |
| - |
70 |
| - |
71 |
| -@pytest.mark.parametrize( |
72 |
| - "blueprint_path", |
73 |
| - [ |
74 |
| - Path("blueprints/tailwind").resolve(strict=True), |
75 |
| - Path("blueprints/bootstrap").resolve(strict=True), |
76 |
| - ], |
77 |
| -) |
78 |
| -def test_start_project_in_directory(blueprint_path, runner: CommandRunner, tmp_path): |
79 |
| - runner.invoke( |
80 |
| - "start-project", |
81 |
| - "dotfm", |
82 |
| - "builds", |
83 |
| - "--blueprint", |
84 |
| - str(blueprint_path), |
85 |
| - ) |
86 |
| - project_dir = tmp_path / "builds" / "dotfm" |
87 |
| - assert project_dir.exists() |
88 |
| - assert all_files_are_correctly_generated("dotfm", project_dir=project_dir) |
89 |
| - |
90 |
| - |
91 |
| -@pytest.mark.parametrize( |
92 |
| - "blueprint_path", |
93 |
| - [ |
94 |
| - Path("blueprints/tailwind").resolve(strict=True), |
95 |
| - Path("blueprints/bootstrap").resolve(strict=True), |
96 |
| - ], |
97 |
| -) |
98 |
| -def test_start_project_in_directory_with_root( |
99 |
| - blueprint_path, runner: CommandRunner, tmp_path |
100 |
| -): |
101 |
| - runner.invoke( |
102 |
| - "start-project", |
103 |
| - "dotfm", |
104 |
| - "builds/special_project", |
105 |
| - "--root", |
106 |
| - "--blueprint", |
107 |
| - str(blueprint_path), |
108 |
| - ) |
109 |
| - project_dir = tmp_path / "builds/special_project" |
110 |
| - assert project_dir.exists() |
111 |
| - assert all_files_are_correctly_generated("dotfm", project_dir=project_dir) |
112 |
| - |
113 |
| - |
114 |
| -@pytest.mark.parametrize( |
115 |
| - "blueprint_path", |
116 |
| - [ |
117 |
| - Path("blueprints/tailwind").resolve(strict=True), |
118 |
| - Path("blueprints/bootstrap").resolve(strict=True), |
119 |
| - ], |
120 |
| -) |
121 |
| -def test_user_name_and_email(blueprint_path, runner: CommandRunner, git_user_infos): |
122 |
| - name, email = git_user_infos |
123 |
| - runner.invoke( |
124 |
| - "start-project", |
125 |
| - "dotfm", |
126 |
| - "--skip-new-version-check", |
127 |
| - "--blueprint", |
128 |
| - str(blueprint_path), |
129 |
| - ) |
130 |
| - pyproject_content = (Path("dotfm") / "pyproject.toml").read_text() |
131 |
| - assert name in pyproject_content |
132 |
| - assert email in pyproject_content |
133 |
| - |
134 |
| - |
135 |
| -# def test_use_local_copy(runner: CommandRunner): |
| 55 | +# |
| 56 | +# |
| 57 | +# # def test_start_project_alias_name(runner: CommandRunner): |
| 58 | +# # runner.invoke( |
| 59 | +# # "start-project", |
| 60 | +# # "dotfm", |
| 61 | +# # "--skip-new-version-check", |
| 62 | +# # "--blueprint", |
| 63 | +# # "tailwind", |
| 64 | +# # ) |
| 65 | +# # assert Path("dotfm").exists() |
| 66 | +# # config = read_falco_config(Path("dotfm/pyproject.toml")) |
| 67 | +# # config_keys = config.keys() |
| 68 | +# # assert "blueprint" in config_keys |
| 69 | +# # assert "revision" in config_keys |
| 70 | +# # assert "work" in config_keys |
| 71 | +# # assert len(config["revision"]) > 10 |
| 72 | +# # |
| 73 | +# # assert all_files_are_correctly_generated("dotfm", project_dir=Path("dotfm")) |
| 74 | +# |
| 75 | +# |
| 76 | +# @pytest.mark.parametrize( |
| 77 | +# "blueprint_path", |
| 78 | +# [ |
| 79 | +# Path("blueprints/tailwind").resolve(strict=True), |
| 80 | +# Path("blueprints/bootstrap").resolve(strict=True), |
| 81 | +# ], |
| 82 | +# ) |
| 83 | +# def test_start_project_in_directory(blueprint_path, runner: CommandRunner, tmp_path): |
136 | 84 | # runner.invoke(
|
137 |
| -# "start-project", "dotfm_cache", "--skip-new-version-check" |
138 |
| -# ) # to make sure the blueprint is downloaded a least once |
139 |
| -# with mock.patch("socket.socket", side_effect=OSError("Network access is cut off")): |
140 |
| -# runner.invoke("start-project", "dotfm", "--skip-new-version-check", "--local") |
141 |
| -# assert Path("dotfm").exists() |
142 |
| -# assert all_files_are_correctly_generated("dotfm", project_dir=Path("dotfm")) |
| 85 | +# "start-project", |
| 86 | +# "dotfm", |
| 87 | +# "builds", |
| 88 | +# "--blueprint", |
| 89 | +# str(blueprint_path), |
| 90 | +# ) |
| 91 | +# project_dir = tmp_path / "builds" / "dotfm" |
| 92 | +# assert project_dir.exists() |
| 93 | +# assert all_files_are_correctly_generated("dotfm", project_dir=project_dir) |
| 94 | +# |
| 95 | +# |
| 96 | +# @pytest.mark.parametrize( |
| 97 | +# "blueprint_path", |
| 98 | +# [ |
| 99 | +# Path("blueprints/tailwind").resolve(strict=True), |
| 100 | +# Path("blueprints/bootstrap").resolve(strict=True), |
| 101 | +# ], |
| 102 | +# ) |
| 103 | +# def test_start_project_in_directory_with_root( |
| 104 | +# blueprint_path, runner: CommandRunner, tmp_path |
| 105 | +# ): |
| 106 | +# runner.invoke( |
| 107 | +# "start-project", |
| 108 | +# "dotfm", |
| 109 | +# "builds/special_project", |
| 110 | +# "--root", |
| 111 | +# "--blueprint", |
| 112 | +# str(blueprint_path), |
| 113 | +# ) |
| 114 | +# project_dir = tmp_path / "builds/special_project" |
| 115 | +# assert project_dir.exists() |
| 116 | +# assert all_files_are_correctly_generated("dotfm", project_dir=project_dir) |
| 117 | +# |
| 118 | +# |
| 119 | +# @pytest.mark.parametrize( |
| 120 | +# "blueprint_path", |
| 121 | +# [ |
| 122 | +# Path("blueprints/tailwind").resolve(strict=True), |
| 123 | +# Path("blueprints/bootstrap").resolve(strict=True), |
| 124 | +# ], |
| 125 | +# ) |
| 126 | +# def test_user_name_and_email(blueprint_path, runner: CommandRunner, git_user_infos): |
| 127 | +# name, email = git_user_infos |
| 128 | +# runner.invoke( |
| 129 | +# "start-project", |
| 130 | +# "dotfm", |
| 131 | +# "--skip-new-version-check", |
| 132 | +# "--blueprint", |
| 133 | +# str(blueprint_path), |
| 134 | +# ) |
| 135 | +# pyproject_content = (Path("dotfm") / "pyproject.toml").read_text() |
| 136 | +# assert name in pyproject_content |
| 137 | +# assert email in pyproject_content |
| 138 | +# |
| 139 | +# |
| 140 | +# # def test_use_local_copy(runner: CommandRunner): |
| 141 | +# # runner.invoke( |
| 142 | +# # "start-project", "dotfm_cache", "--skip-new-version-check" |
| 143 | +# # ) # to make sure the blueprint is downloaded a least once |
| 144 | +# # with mock.patch("socket.socket", side_effect=OSError("Network access is cut off")): |
| 145 | +# # runner.invoke("start-project", "dotfm", "--skip-new-version-check", "--local") |
| 146 | +# # assert Path("dotfm").exists() |
| 147 | +# # assert all_files_are_correctly_generated("dotfm", project_dir=Path("dotfm")) |
0 commit comments