"""trade_result_lib:过滤「错过」记录."""
import unittest

from lib.trade.trade_result_lib import (
    filter_trade_records_excluding_miss,
    is_miss_trade_result,
)


class TradeResultMissFilterTest(unittest.TestCase):
    def test_is_miss_trade_result(self):
        self.assertTrue(is_miss_trade_result("错过"))
        self.assertFalse(is_miss_trade_result("止盈"))

    def test_filter_excludes_miss(self):
        rows = [
            {"effective_result": "止盈", "id": 1},
            {"effective_result": "错过", "id": 2},
            {"result": "错过", "id": 3},
        ]
        out = filter_trade_records_excluding_miss(rows)
        self.assertEqual([r["id"] for r in out], [1])


if __name__ == "__main__":
    unittest.main()
