Skip to content

Commit

Permalink
Add mroe tests and fix defaults
Browse files Browse the repository at this point in the history
  • Loading branch information
thatch committed Jan 20, 2024
1 parent c79de6d commit 779d2e5
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 4 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:
pull_request:

jobs:
checkreqs:
checkdeps:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
Expand All @@ -34,3 +34,5 @@ jobs:
run: make test
- name: Lint
run: make lint
- name: Checkdeps
run: make checkdeps
49 changes: 46 additions & 3 deletions checkdeps/tests/cli.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os
import re
import tempfile

Expand Down Expand Up @@ -27,7 +28,8 @@ def test_basic(self) -> None:
(pd / "requirements.txt").write_text("")

runner = CliRunner()
result = runner.invoke(main, [f"--requirements={d}/requirements.txt", d])
result = runner.invoke(main, [f"--requirements={d}/requirements.txt",
"--no-metadata", d])
output = MOD_RE.sub("[TEMPDIR]/mod", result.output)
self.assertEqual(
"""\
Expand All @@ -41,7 +43,8 @@ def test_basic(self) -> None:
runner = CliRunner()
result = runner.invoke(
main,
[f"--requirements={d}/requirements.txt", "--missing-projects-only", d],
[f"--requirements={d}/requirements.txt", "--missing-projects-only",
"--no-metadata", d],
)
output = MOD_RE.sub("[TEMPDIR]/mod", result.output)
self.assertEqual(
Expand All @@ -56,7 +59,7 @@ def test_basic(self) -> None:
(pd / "requirements.txt").write_text("click==9\n# comment\n")
runner = CliRunner()
result = runner.invoke(
main, [f"--requirements={d}/requirements.txt", "--verbose", d]
main, [f"--requirements={d}/requirements.txt", "--no-metadata", "--verbose", d]
)
output = MOD_RE.sub("[TEMPDIR]/mod", result.output)
self.assertEqual(
Expand All @@ -66,6 +69,46 @@ def test_basic(self) -> None:
[TEMPDIR]/mod/foo.py uses baz.fromimport but there is nothing installed to provide it
click available from ['click']
sys stdlib
""",
output,
)
def test_metadata(self) -> None:
with tempfile.TemporaryDirectory() as d:
pd = Path(d).resolve()
(pd / "mod").mkdir()
(pd / "mod" / "foo.py").write_text(
"""\
import sys
import bar
import click
from baz import fromimport
"""
)
(pd / "pyproject.toml").write_text("[project]\n")

runner = CliRunner()
os.chdir(pd) # TODO wish this wasn't required
result = runner.invoke(main, [d])
output = MOD_RE.sub("[TEMPDIR]/mod", result.output)
self.assertEqual(
"""\
[TEMPDIR]/mod/foo.py uses bar but there is nothing installed to provide it
[TEMPDIR]/mod/foo.py uses baz.fromimport but there is nothing installed to provide it
[TEMPDIR]/mod/foo.py uses click but 'click' not in requirements
""",
output,
)

(pd / "pyproject.toml").write_text("[project]\ndependencies = ['click', 'bar']")

runner = CliRunner()
os.chdir(pd) # TODO wish this wasn't required
result = runner.invoke(main, [d])
output = MOD_RE.sub("[TEMPDIR]/mod", result.output)
self.assertEqual(
"""\
[TEMPDIR]/mod/foo.py uses bar but there is nothing installed to provide it
[TEMPDIR]/mod/foo.py uses baz.fromimport but there is nothing installed to provide it
""",
output,
)

0 comments on commit 779d2e5

Please sign in to comment.