Update Discord trade listings
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import unittest
|
||||
|
||||
from bundle_quotes import extract_bundle_quotes, parse_bundle
|
||||
from provisional_valuelist import fit_values
|
||||
from provisional_valuelist import conflicting_quotes, fit_values
|
||||
|
||||
|
||||
class ProvisionalValueListTests(unittest.TestCase):
|
||||
@@ -27,6 +27,58 @@ class ProvisionalValueListTests(unittest.TestCase):
|
||||
self.assertEqual(shiny["relative_value"], "")
|
||||
self.assertEqual(shiny["confidence"], "constraint_only")
|
||||
|
||||
def test_conflicting_direct_quotes_show_both_sources(self):
|
||||
direct = [
|
||||
{"offered_unit": "Homura Evo", "offered_qty": 2,
|
||||
"requested_unit": "Alucard Evo", "requested_qty": 1,
|
||||
"source_row": 10, "source_text": "2 Homura Evo for Alucard Evo"},
|
||||
{"offered_unit": "Homura Evo", "offered_qty": 1,
|
||||
"requested_unit": "Alucard Evo", "requested_qty": 1,
|
||||
"source_row": 20, "source_text": "Homura Evo for Alucard Evo"},
|
||||
]
|
||||
conflicts = conflicting_quotes(direct)
|
||||
self.assertEqual(len(conflicts), 1)
|
||||
self.assertEqual((conflicts[0]["source_row_a"], conflicts[0]["source_row_b"]), (10, 20))
|
||||
self.assertEqual(conflicts[0]["ratio_difference_pct"], 100.0)
|
||||
|
||||
def test_influential_quote_removes_numeric_rank(self):
|
||||
direct = [
|
||||
{"offered_unit": "Homura Evo", "offered_qty": qty,
|
||||
"requested_unit": "Aizen Evo", "requested_qty": 1,
|
||||
"source_row": row, "source_text": f"{qty} Homura Evo for Aizen Evo"}
|
||||
for row, qty in ((2, 1), (3, 1), (4, 10))
|
||||
]
|
||||
rows, _, report, _, impacts = fit_values(direct, [], include_report=True)
|
||||
homura = next(row for row in rows if row["unit_variant"] == "Homura Evo")
|
||||
evidence = next(row for row in report if row["unit_variant"] == "Homura Evo")
|
||||
self.assertEqual(homura["confidence"], "unstable")
|
||||
self.assertEqual((homura["rank"], homura["relative_value"]), ("", ""))
|
||||
self.assertGreater(evidence["max_change_pct"], 25)
|
||||
self.assertEqual(evidence["most_influential_source_row"], 4)
|
||||
removed_outlier = next(item for item in impacts if item["unit_variant"] == "Homura Evo"
|
||||
and item["removed_source_row"] == 4)
|
||||
self.assertGreater(removed_outlier["change_pct"], 25)
|
||||
|
||||
def test_bridge_quote_disconnects_variant(self):
|
||||
direct = [
|
||||
{"offered_unit": "Homura Evo", "offered_qty": 1,
|
||||
"requested_unit": "Aizen Evo", "requested_qty": 1,
|
||||
"source_row": 2, "source_text": "Homura for Aizen"},
|
||||
*({"offered_unit": "Chuuni Evo", "offered_qty": 1,
|
||||
"requested_unit": "Homura Evo", "requested_qty": 1,
|
||||
"source_row": row, "source_text": "Chuuni for Homura"}
|
||||
for row in (3, 4, 5)),
|
||||
]
|
||||
rows, _, report, _, impacts = fit_values(direct, [], include_report=True)
|
||||
chuuni = next(row for row in rows if row["unit_variant"] == "Chuuni Evo")
|
||||
evidence = next(row for row in report if row["unit_variant"] == "Chuuni Evo")
|
||||
self.assertEqual(chuuni["confidence"], "unstable")
|
||||
self.assertEqual(chuuni["rank"], "")
|
||||
self.assertEqual(evidence["disconnects_when_removed"], "2")
|
||||
bridge = next(item for item in impacts if item["unit_variant"] == "Chuuni Evo"
|
||||
and item["removed_source_row"] == 2)
|
||||
self.assertEqual((bridge["leave_one_out_value"], bridge["disconnected"]), ("", "yes"))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user