Skip to content

Commit 9605ab5

Browse files
Simplify CLI path handling and add www functional tests
1 parent 4a6d931 commit 9605ab5

3 files changed

Lines changed: 9 additions & 15 deletions

File tree

pythoncms/cli.py

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -41,26 +41,13 @@ def cli():
4141
@click.option("--run", is_flag=True, help="Initialize and run the server immediately")
4242
def start(name, run):
4343
"""Create a new pythoncms project"""
44-
try:
45-
current_dir = Path.cwd()
46-
except FileNotFoundError:
47-
# Self-healing: if directory was deleted and recreated, try to recover from PWD env
48-
pwd = os.environ.get("PWD")
49-
if pwd and os.path.exists(pwd):
50-
current_dir = Path(pwd)
51-
else:
52-
click.echo(
53-
"Error: Your current directory has been deleted. Please 'cd' out and back in."
54-
)
55-
return
56-
57-
dest = os.path.join(str(current_dir), name)
58-
44+
dest = os.path.abspath(name)
5945

6046
if os.path.exists(dest):
6147
click.echo(f"Error: Directory {name} already exists.")
6248
return
6349

50+
6451
# Copy the project structure
6552
trycopytree(str(path.parent.absolute()), dest)
6653

pythoncms/modules/www/tests/__init__.py

Whitespace-only changes.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import pytest
2+
3+
def test_www_index(test_client):
4+
response = test_client.get("/")
5+
assert response.status_code == 200
6+
# Editorial theme default title check
7+
assert b"Editorial" in response.data or b"Hyperspace" in response.data

0 commit comments

Comments
 (0)