Skip to content

Commit

Permalink
fix: support object structure in schema (#231)
Browse files Browse the repository at this point in the history
Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
  • Loading branch information
henryiii authored Aug 19, 2024
1 parent 1bb0212 commit 7033441
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 2 deletions.
13 changes: 12 additions & 1 deletion src/repo_review/resources/repo-review.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,18 @@
"$ref": "#/$defs/checks"
},
"ignore": {
"$ref": "#/$defs/checks"
"oneOf": [
{
"$ref": "#/$defs/checks"
},
{
"type": "object",
"patternProperties": {
"^[A-Z]+[0-9]*$": { "type": "string" }
},
"additionalProperties": false
}
]
}
},
"$defs": {
Expand Down
37 changes: 36 additions & 1 deletion tests/test_package.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,45 @@ def test_broken_validate_pyproject(tmp_path: Path) -> None:
results = process(tmp_path)

(result,) = (r for r in results.results if r.name == "VPP001")
assert "must match pattern" in result.err_msg
assert "must be valid exactly by one definition" in result.err_msg
assert not result.result


def test_broken_validate_pyproject_object(tmp_path: Path) -> None:
pytest.importorskip("validate_pyproject")
tmp_path.joinpath("pyproject.toml").write_text(
textwrap.dedent(
"""\
[tool.repo-review.ignore]
a2 = "some message"
"""
)
)

results = process(tmp_path)

(result,) = (r for r in results.results if r.name == "VPP001")
assert "must be valid exactly by one definition" in result.err_msg
assert not result.result


def test_working_validate_pyproject_object(tmp_path: Path) -> None:
pytest.importorskip("validate_pyproject")
tmp_path.joinpath("pyproject.toml").write_text(
textwrap.dedent(
"""\
[tool.repo-review.ignore]
PP102 = "some message"
"""
)
)

results = process(tmp_path)

(result,) = (r for r in results.results if r.name == "VPP001")
assert result.result


def test_testing_function():
pytest.importorskip("sp_repo_review")

Expand Down

0 comments on commit 7033441

Please sign in to comment.