-
-
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.
- Loading branch information
Showing
1 changed file
with
29 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,37 @@ | ||
"""Test arg parsing.""" | ||
|
||
# std | ||
from pathlib import Path | ||
from shlex import split | ||
|
||
# lib | ||
import pytest | ||
|
||
# pkg | ||
from cosmofy.args import Args | ||
|
||
|
||
def test_empty() -> None: | ||
"""Empty args.""" | ||
assert Args.parse([]) == Args() | ||
|
||
|
||
def test_basic() -> None: | ||
"""Basic flags.""" | ||
assert Args.parse( | ||
split("--clone --args '-m foo' --output bar/baz src/repo") | ||
) == Args(clone=True, args="-m foo", output=Path("bar/baz"), add=["src/repo"]) | ||
|
||
|
||
def test_disable_cache() -> None: | ||
"""Disable cache.""" | ||
assert Args.parse(split("--cache 0")) == Args(cache=None) | ||
assert Args.parse(split("--cache false")) == Args(cache=None) | ||
assert Args.parse(split("--cache False")) == Args(cache=None) | ||
assert Args.parse(split("--cache FALSE")) == Args(cache=None) | ||
|
||
|
||
def test_bad_arg() -> None: | ||
"""Bad arg.""" | ||
with pytest.raises(ValueError): | ||
Args.parse(["--unknown"]) |