Skip to content

Commit

Permalink
add test for overriding DUD_LOAD_RULE_PATHS
Browse files Browse the repository at this point in the history
  • Loading branch information
BurnzZ committed Jul 8, 2024
1 parent 9f6eb73 commit 9b895a9
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion tests/test_fingerprinter.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,28 @@ def get_stat(stat: str) -> Any:
default_rule_paths = None


def test_default_rules():
def test_default_rules(tmp_path):
fingerprinter = get_fingerprinter({})
if default_rule_paths:
assert len(fingerprinter.url_canonicalizer.processors) > 0
else:
assert len(fingerprinter.url_canonicalizer.processors) == 0

# Regardless of the presence of the ``duplicate_url_discarder_rules`` package,
# as long as the ``DUD_LOAD_RULE_PATHS`` setting is set, rules on that will be used.

rules_path = Path(tmp_path) / "single_rule.json"
rules_path.write_text(
json.dumps(
[
{
"args": ["PHPSESSIONID"],
"order": 1,
"processor": "queryRemoval",
"urlPattern": {"include": []},
},
]
)
)
fingerprinter = get_fingerprinter({"DUD_LOAD_RULE_PATHS": [str(rules_path)]})
assert len(fingerprinter.url_canonicalizer.processors) == 1

0 comments on commit 9b895a9

Please sign in to comment.