-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PA-655 dummy command for creating new-style websites. by: Piotr, Giles
- Loading branch information
Showing
4 changed files
with
128 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#!/usr/bin/python3 | ||
import typer | ||
from typing_extensions import Annotated | ||
|
||
|
||
app = typer.Typer(no_args_is_help=True) | ||
|
||
@app.command() | ||
def create( | ||
domain_name: Annotated[ | ||
str, | ||
typer.Option( | ||
"-d", | ||
"--domain", | ||
help="Domain name, eg. yourusername.pythonanywhere.com or www.mydomain.com", | ||
) | ||
], | ||
command: Annotated[ | ||
str, | ||
typer.Option( | ||
"-c", | ||
"--command", | ||
help="The command to start up your server", | ||
) | ||
], | ||
): | ||
"""Create an ASGI website""" | ||
pass | ||
|
||
|
||
@app.command() | ||
def delete(): | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
from typer.testing import CliRunner | ||
|
||
from cli.website import app | ||
|
||
runner = CliRunner() | ||
|
||
|
||
def test_main_subcommand_without_args_prints_help(): | ||
result = runner.invoke( | ||
app, | ||
[], | ||
) | ||
assert result.exit_code == 0 | ||
assert "Show this message and exit." in result.stdout | ||
|
||
|
||
def test_create_without_domain_barfs(): | ||
result = runner.invoke( | ||
app, | ||
[ | ||
"create", | ||
"-c", | ||
"some kind of server", | ||
], | ||
) | ||
assert result.exit_code != 0 | ||
assert "Missing option" in result.stdout | ||
|
||
|
||
def test_create_without_command_barfs(): | ||
result = runner.invoke( | ||
app, | ||
[ | ||
"create", | ||
"-d", | ||
"www.something.com", | ||
], | ||
) | ||
assert result.exit_code != 0 | ||
assert "Missing option" in result.stdout | ||
|
||
|
||
def test_create_with_domain_and_command_does_something(): | ||
result = runner.invoke( | ||
app, | ||
[ | ||
"create", | ||
"-d", | ||
"www.something.com", | ||
"-c", | ||
"some kind of server", | ||
], | ||
) | ||
assert result.exit_code == 0 | ||
|
||
|