-
-
Notifications
You must be signed in to change notification settings - Fork 675
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
98 additions
and
38 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
Empty file.
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,9 @@ | ||
import typer | ||
|
||
from .users import app as users_app | ||
from .version import app as version_app | ||
|
||
app = typer.Typer() | ||
|
||
app.add_typer(version_app) | ||
app.add_typer(users_app, name="users") |
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,9 @@ | ||
import typer | ||
|
||
from .add import app as add_app | ||
from .delete import app as delete_app | ||
|
||
app = typer.Typer() | ||
|
||
app.add_typer(add_app) | ||
app.add_typer(delete_app) |
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,8 @@ | ||
import typer | ||
|
||
app = typer.Typer() | ||
|
||
|
||
@app.command() | ||
def add(name: str): | ||
typer.echo(f"Adding user: {name}") |
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,8 @@ | ||
import typer | ||
|
||
app = typer.Typer() | ||
|
||
|
||
@app.command() | ||
def delete(name: str): | ||
typer.echo(f"Deleting user: {name}") |
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,8 @@ | ||
import typer | ||
|
||
app = typer.Typer() | ||
|
||
|
||
@app.command() | ||
def version(): | ||
typer.echo("My CLI Version 1.0") |
Empty file.
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,48 @@ | ||
import os | ||
import subprocess | ||
import sys | ||
|
||
from typer.testing import CliRunner | ||
|
||
from docs_src.splitting_apps import main as mod | ||
|
||
runner = CliRunner() | ||
|
||
|
||
def test_help(): | ||
result = runner.invoke(mod.app, ["--help"]) | ||
|
||
assert result.exit_code == 0 | ||
|
||
assert "version" in result.output | ||
assert "users" in result.output | ||
|
||
|
||
def test_version(): | ||
result = runner.invoke(mod.app, ["version"]) | ||
|
||
assert result.exit_code == 0 | ||
assert "My CLI Version 1.0" in result.output | ||
|
||
|
||
def test_users_help(): | ||
result = runner.invoke(mod.app, ["users", "--help"]) | ||
|
||
assert result.exit_code == 0 | ||
|
||
assert "add" in result.output | ||
assert "delete" in result.output | ||
|
||
|
||
def test_add_user(): | ||
result = runner.invoke(mod.app, ["users", "add", "Camila"]) | ||
|
||
assert result.exit_code == 0 | ||
assert "Adding user: Camila" in result.output | ||
|
||
|
||
def test_delete_user(): | ||
result = runner.invoke(mod.app, ["users", "delete", "Camila"]) | ||
|
||
assert result.exit_code == 0 | ||
assert "Deleting user: Camila" in result.output |