Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests: add an extra test file #204

Merged
merged 1 commit into from
Apr 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 61 additions & 0 deletions tests/test_depends.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
from pathlib import Path

import pytest

import repo_review.processor
from repo_review._compat.importlib.resources.abc import Traversable


class E100:
"Was passed correctly"

family = "example"

@staticmethod
def check(package: Traversable) -> bool:
"""
Requires Path(".") to be passed
"""

return package == Path()


class E200:
"Always true"

family = "example"
requires = frozenset(["E100"])

@staticmethod
def check() -> bool:
"""
Can't be false.
"""

return True


def test_ignore_filter_single(monkeypatch: pytest.MonkeyPatch) -> None:
monkeypatch.setattr(
repo_review.processor,
"collect_checks",
lambda _: {"E100": E100, "E200": E200},
)
_, results = repo_review.processor.process(Path(), ignore={"E100"})

assert len(results) == 1
assert results[0].name == "E200"
assert results[0].result


def test_select_filter_single(monkeypatch: pytest.MonkeyPatch) -> None:
monkeypatch.setattr(
repo_review.processor,
"collect_checks",
lambda _: {"E100": E100, "E200": E200},
)
_, results = repo_review.processor.process(Path(), select={"E200"})

assert len(results) == 1
assert results[0].name == "E200"
assert results[0].result
Loading