bug fix to avoid swallowing exceptions/failed pages inside fetch_all_pages/small refactor
This commit is contained in:
1 parent
321546f9b9
commit
b071ac35bf
17 files changed
+309
-1650
No files matched your search
@@ -8,7 +8,11 @@ Mongo. The claim query sorts priority descending, so a priority of 0 means an
|
||||
alert is only drained once everything else is.
|
||||
"""
|
||||
|
||||
from monitor_utils.database import NO_MSRP_PRIORITY, calculate_priority
|
||||
from monitor_utils.database import (
|
||||
NEW_LISTING_PRIORITY,
|
||||
NO_MSRP_PRIORITY,
|
||||
calculate_priority,
|
||||
)
|
||||
|
||||
|
||||
def document(current, original, **overrides) -> dict:
|
||||
@@ -44,3 +48,21 @@ def test_broken_prices_still_outrank_nothing():
|
||||
assert calculate_priority(document(50.0, None, hasMsrp=False)) == 0
|
||||
assert calculate_priority(document(50.0, 0, hasMsrp=False)) == 0
|
||||
assert calculate_priority(document(None, 100.0, hasMsrp=False)) == 0
|
||||
|
||||
|
||||
def test_new_listing_is_floored_not_buried():
|
||||
"""A low-discount new listing sends regardless, so it must not sort last."""
|
||||
assert (
|
||||
calculate_priority(document(95.0, 100.0, newListing=True))
|
||||
== NEW_LISTING_PRIORITY
|
||||
)
|
||||
|
||||
|
||||
def test_new_listing_keeps_a_higher_percentage_rank():
|
||||
"""The floor is a floor: a 75%-off new listing still ranks as 75% off."""
|
||||
assert calculate_priority(document(25.0, 100.0, newListing=True)) == 7
|
||||
|
||||
|
||||
def test_repeat_alerts_keep_the_percentage_path():
|
||||
assert calculate_priority(document(95.0, 100.0, newListing=False)) == 0
|
||||
assert calculate_priority(document(95.0, 100.0)) == 0
|
||||
Reference in new issue
Block a user