Skip to content

Commit dc51221

Browse files
authored
tests: add an extra test file (#204)
Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
1 parent df151f1 commit dc51221

File tree

1 file changed

+61
-0
lines changed

1 file changed

+61
-0
lines changed

tests/test_depends.py

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
from pathlib import Path
2+
3+
import pytest
4+
5+
import repo_review.processor
6+
from repo_review._compat.importlib.resources.abc import Traversable
7+
8+
9+
class E100:
10+
"Was passed correctly"
11+
12+
family = "example"
13+
14+
@staticmethod
15+
def check(package: Traversable) -> bool:
16+
"""
17+
Requires Path(".") to be passed
18+
"""
19+
20+
return package == Path()
21+
22+
23+
class E200:
24+
"Always true"
25+
26+
family = "example"
27+
requires = frozenset(["E100"])
28+
29+
@staticmethod
30+
def check() -> bool:
31+
"""
32+
Can't be false.
33+
"""
34+
35+
return True
36+
37+
38+
def test_ignore_filter_single(monkeypatch: pytest.MonkeyPatch) -> None:
39+
monkeypatch.setattr(
40+
repo_review.processor,
41+
"collect_checks",
42+
lambda _: {"E100": E100, "E200": E200},
43+
)
44+
_, results = repo_review.processor.process(Path(), ignore={"E100"})
45+
46+
assert len(results) == 1
47+
assert results[0].name == "E200"
48+
assert results[0].result
49+
50+
51+
def test_select_filter_single(monkeypatch: pytest.MonkeyPatch) -> None:
52+
monkeypatch.setattr(
53+
repo_review.processor,
54+
"collect_checks",
55+
lambda _: {"E100": E100, "E200": E200},
56+
)
57+
_, results = repo_review.processor.process(Path(), select={"E200"})
58+
59+
assert len(results) == 1
60+
assert results[0].name == "E200"
61+
assert results[0].result

0 commit comments

Comments
 (0)