From 9b895a9825e65ffc576e54de2f8832c894abaff3 Mon Sep 17 00:00:00 2001 From: Kevin Lloyd Bernal Date: Mon, 8 Jul 2024 18:29:45 +1000 Subject: [PATCH] add test for overriding DUD_LOAD_RULE_PATHS --- tests/test_fingerprinter.py | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/tests/test_fingerprinter.py b/tests/test_fingerprinter.py index be515fe..ad5ce59 100644 --- a/tests/test_fingerprinter.py +++ b/tests/test_fingerprinter.py @@ -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