| | |
| | | |
| | | |
| | | class DataUpdateV2BaoStockTests(unittest.TestCase): |
| | | def test_fetch_akshare_stock_list_prefers_exchange_code_name_api(self): |
| | | class FakeAkShare: |
| | | def stock_info_a_code_name(self): |
| | | return pd.DataFrame( |
| | | [ |
| | | {"code": "000001", "name": "平安银行"}, |
| | | {"code": "600519", "name": "贵州茅台"}, |
| | | ] |
| | | ) |
| | | |
| | | def stock_zh_a_spot_em(self): |
| | | raise AssertionError("stock_zh_a_spot_em should not be called") |
| | | |
| | | result = data_update_v2.fetch_akshare_stock_list(FakeAkShare()) |
| | | |
| | | self.assertEqual( |
| | | result.to_dict("records"), |
| | | [ |
| | | {"代码": "000001", "名称": "平安银行"}, |
| | | {"代码": "600519", "名称": "贵州茅台"}, |
| | | ], |
| | | ) |
| | | |
| | | def test_convert_baostock_history_matches_existing_schema(self): |
| | | raw = pd.DataFrame( |
| | | [ |