46 lines
2.1 KiB
Python
46 lines
2.1 KiB
Python
import unittest
|
|
|
|
from bundle_quotes import extract_bundle_quotes
|
|
from extract_exchange_quotes import extract_quotes, parse_side
|
|
|
|
|
|
class ExchangeQuoteTests(unittest.TestCase):
|
|
def test_stat_specific_inventory_is_not_a_base_variant_quote(self):
|
|
rows = [
|
|
{"author_hash": "a", "offer": "Homura Evo (SSS RNG)",
|
|
"lf": "my Homura Evo for Alucard Evo", "mlf": ""},
|
|
{"author_hash": "b", "offer": "Homura Evo (SSS RNG) | Homura Evo",
|
|
"lf": "my Homura Evo for Alucard Evo", "mlf": ""},
|
|
{"author_hash": "c", "offer": "Shiny Poseidon Evo | 14x Dark Mage Evo (A+/SSS/SS) | 2x Chuuni Evo",
|
|
"lf": "My Shiny Poseidon Evo, 1 Dark Mage Evo, 2x Chuuni Evo for Homura Evo",
|
|
"mlf": ""},
|
|
{"author_hash": "d", "offer": "2x Homura Evo 1 s,s,A, Alucard Evo",
|
|
"lf": "", "mlf": "my 2x Homura Evo for Aizen Evo"},
|
|
]
|
|
self.assertEqual([q["source_row"] for q in extract_quotes(rows)], [3])
|
|
self.assertEqual(extract_bundle_quotes(rows), [])
|
|
|
|
def test_only_exact_variant_and_quantity(self):
|
|
self.assertEqual(parse_side("my 2 Shiny Aizen Evo"),
|
|
("Shiny Aizen Evo", 2, "my"))
|
|
self.assertIsNone(parse_side("Shiny Aizen Evo + adds"))
|
|
self.assertIsNone(parse_side("Aizen Evo or Homura Evo"))
|
|
|
|
def test_owner_direction_deduplication_and_ambiguous_listing(self):
|
|
rows = [
|
|
{"author_hash": "a", "offer": "Homura Evo | Dark Mage Evo",
|
|
"lf": "Aizen Evo for my Homura Evo", "mlf": "", "nlf": ""},
|
|
{"author_hash": "a", "offer": "Homura Evo",
|
|
"lf": "Aizen Evo for my Homura Evo", "mlf": "", "nlf": ""},
|
|
{"author_hash": "b", "offer": "Shiny Aizen Evo | Homura Evo",
|
|
"lf": "Aizen Evo", "mlf": "", "nlf": ""},
|
|
]
|
|
quotes = extract_quotes(rows)
|
|
self.assertEqual(len(quotes), 1)
|
|
self.assertEqual(quotes[0]["offered_unit"], "Homura Evo")
|
|
self.assertEqual(quotes[0]["requested_unit"], "Aizen Evo")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|