Skip to content

Commit

Permalink
add: arg tests (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
metaist committed Sep 13, 2024
1 parent 7f0ebbe commit 6e0b200
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions test/test_args.py
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"])

0 comments on commit 6e0b200

Please sign in to comment.