-
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
4 changed files
with
63 additions
and
4 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
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
55 changes: 55 additions & 0 deletions
55
tests/queryRemovalExcept/test_query_removal_except_main.py
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,55 @@ | ||
from duplicate_url_discarder.url_canonicalizer import UrlCanonicalizer | ||
from duplicate_url_discarder.processors import QueryRemovalExceptProcessor | ||
|
||
from duplicate_url_discarder_rules import RULE_PATHS | ||
|
||
|
||
def test_query_removal_except_main_rules(): | ||
rule_path = [ | ||
path for path in RULE_PATHS if path.endswith("queryRemovalExcept/main.json") | ||
] | ||
assert len(rule_path) == 1 | ||
|
||
canonicalizer = UrlCanonicalizer(rule_path) | ||
|
||
assert len(canonicalizer.processors) == 1 | ||
assert isinstance( | ||
list(canonicalizer.processors.values())[0], QueryRemovalExceptProcessor | ||
) | ||
|
||
domains = [ | ||
"ae", | ||
"ca", | ||
"cn", | ||
"co.jp", | ||
"co.uk", | ||
"com.au", | ||
"com.br", | ||
"com.mx", | ||
"com.sg", | ||
"com.tr", | ||
"com", | ||
"de", | ||
"es", | ||
"fr", | ||
"in", | ||
"it", | ||
"nl", | ||
"pt", | ||
"sa", | ||
"se", | ||
] | ||
|
||
for domain in domains: | ||
assert ( | ||
canonicalizer.process_url( | ||
f"https://www.amazon.{domain}/some-text/dp/ASIN?p=1&q=2#frag" | ||
) | ||
== f"https://www.amazon.{domain}/some-text/dp/ASIN#frag" | ||
) | ||
assert ( | ||
canonicalizer.process_url( | ||
f"https://www.amazon.{domain}/dp/ASIN?p=1&q=2#frag" | ||
) | ||
== f"https://www.amazon.{domain}/dp/ASIN#frag" | ||
) |
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