-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
72 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions | ||
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions | ||
|
||
name: tox | ||
|
||
on: | ||
pull_request: | ||
push: | ||
branches: [ main ] | ||
|
||
jobs: | ||
test: | ||
|
||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
include: | ||
- python-version: "3.8" | ||
- python-version: "3.9" | ||
- python-version: "3.10" | ||
- python-version: "3.11" | ||
- python-version: "3.12" | ||
- python-version: "3.12" | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
python -m pip install tox | ||
- name: tox | ||
run: | | ||
tox -e ${{ matrix.toxenv || 'py' }} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import json | ||
|
||
from url_matcher import Patterns | ||
|
||
from duplicate_url_discarder_rules import RULE_PATHS | ||
|
||
|
||
def test_rule_validity(): | ||
for path in RULE_PATHS: | ||
try: | ||
with open(path, "r") as f: | ||
data = json.loads(f.read()) | ||
except Exception as e: | ||
raise ValueError(f"Something went wrong when reading '{path}': {str(e)}.") | ||
|
||
assert isinstance( | ||
data, list | ||
), f"The rules should be a list: '{path}'. Got {type(data)}." | ||
|
||
for rule in data: | ||
order = rule.get("order") | ||
assert order is not None, path | ||
assert isinstance(order, int), path | ||
|
||
url_pattern = rule.get("urlPattern") | ||
assert isinstance(url_pattern, dict), path | ||
assert isinstance(url_pattern["include"], list), path | ||
assert Patterns(url_pattern) | ||
|
||
assert rule.get("processor"), path | ||
assert isinstance(rule.get("processor"), str), path | ||
|
||
if "args" in rule: | ||
assert isinstance(rule["args"], (list, tuple)) |