30 lines
1.2 KiB
Python
30 lines
1.2 KiB
Python
import unittest
|
|
|
|
from extract_exchange_quotes import extract_quotes, parse_side
|
|
|
|
|
|
class ExchangeQuoteTests(unittest.TestCase):
|
|
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()
|