-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18 from trappitsch/cli_test
Unit test for CLI `cowsay`
- Loading branch information
Showing
3 changed files
with
43 additions
and
0 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
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,38 @@ | ||
# Build the `cowsay` project with PyApp. | ||
|
||
import os | ||
from pathlib import Path | ||
|
||
from click.testing import CliRunner | ||
from git import Repo | ||
import pytest | ||
|
||
from box.cli import cli | ||
|
||
|
||
GIT_URL = "https://github.com/VaasuDevanS/cowsay-python.git" # repo for qtcowsay | ||
COMMIT_HASH = "3db622cefd8b11620ece7386d4151b5e734b078b" # commit hash for v6.1 | ||
|
||
|
||
@pytest.mark.unit | ||
def test_gui_build(): | ||
"""Build the `qtcowsay` project with PyApp.""" | ||
runner = CliRunner() | ||
with runner.isolated_filesystem(): | ||
# app expected | ||
app_expected = Path("target/release/cowsay") | ||
if os.name == "nt": # on windows with have an .exe! | ||
app_expected = app_expected.with_suffix(".exe") | ||
|
||
# clone the repo | ||
repo = Repo.clone_from(GIT_URL, ".") | ||
repo.git.checkout(COMMIT_HASH) # prevent repo-jacking | ||
|
||
# init and build | ||
runner.invoke(cli, ["init", "-q", "-b", "build"]) | ||
result = runner.invoke(cli, ["package"]) | ||
|
||
# check result | ||
assert result.exit_code == 0 | ||
assert "Project successfully packaged" in result.output | ||
assert app_expected.exists() |