lib-x17-fintech 2.1.3__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (282) hide show
  1. lib_x17_fintech-2.1.3.dist-info/METADATA +633 -0
  2. lib_x17_fintech-2.1.3.dist-info/RECORD +282 -0
  3. lib_x17_fintech-2.1.3.dist-info/WHEEL +5 -0
  4. lib_x17_fintech-2.1.3.dist-info/licenses/LICENSE +1 -0
  5. lib_x17_fintech-2.1.3.dist-info/top_level.txt +1 -0
  6. xfintech/__init__.py +0 -0
  7. xfintech/connect/__init__.py +18 -0
  8. xfintech/connect/artifact/__init__.py +5 -0
  9. xfintech/connect/artifact/artifact.py +168 -0
  10. xfintech/connect/artifact/tests/__init__.py +3 -0
  11. xfintech/connect/artifact/tests/test_class_artifact_all.py +564 -0
  12. xfintech/connect/common/__init__.py +12 -0
  13. xfintech/connect/common/connect.py +49 -0
  14. xfintech/connect/common/connectref.py +119 -0
  15. xfintech/connect/common/error.py +62 -0
  16. xfintech/connect/common/tests/__init__.py +1 -0
  17. xfintech/connect/common/tests/test_class_connectlike_all.py +544 -0
  18. xfintech/connect/common/tests/test_class_connectref_all.py +586 -0
  19. xfintech/connect/common/tests/test_class_errors_all.py +524 -0
  20. xfintech/connect/instance/__init__.py +7 -0
  21. xfintech/connect/instance/macos.py +121 -0
  22. xfintech/connect/instance/s3.py +176 -0
  23. xfintech/connect/instance/tests/__init__.py +1 -0
  24. xfintech/connect/instance/tests/test_class_macosconnect_all.py +692 -0
  25. xfintech/connect/instance/tests/test_class_s3connect_all.py +603 -0
  26. xfintech/data/__init__.py +20 -0
  27. xfintech/data/common/__init__.py +15 -0
  28. xfintech/data/common/cache.py +186 -0
  29. xfintech/data/common/coolant.py +171 -0
  30. xfintech/data/common/metric.py +138 -0
  31. xfintech/data/common/paginate.py +132 -0
  32. xfintech/data/common/params.py +162 -0
  33. xfintech/data/common/retry.py +201 -0
  34. xfintech/data/common/tests/__init__.py +1 -0
  35. xfintech/data/common/tests/test_class_cache_all.py +681 -0
  36. xfintech/data/common/tests/test_class_coolant_all.py +534 -0
  37. xfintech/data/common/tests/test_class_metric_all.py +705 -0
  38. xfintech/data/common/tests/test_class_paginate_all.py +508 -0
  39. xfintech/data/common/tests/test_class_params_all.py +891 -0
  40. xfintech/data/common/tests/test_class_retry_all.py +714 -0
  41. xfintech/data/job/__init__.py +17 -0
  42. xfintech/data/job/errors.py +112 -0
  43. xfintech/data/job/house.py +156 -0
  44. xfintech/data/job/job.py +247 -0
  45. xfintech/data/job/joblike.py +47 -0
  46. xfintech/data/job/tests/__init__.py +1 -0
  47. xfintech/data/job/tests/test_class_errors_all.py +275 -0
  48. xfintech/data/job/tests/test_class_house_all.py +801 -0
  49. xfintech/data/job/tests/test_class_job_all.py +684 -0
  50. xfintech/data/job/tests/test_class_joblike_all.py +482 -0
  51. xfintech/data/relay/__init__.py +7 -0
  52. xfintech/data/relay/client.py +114 -0
  53. xfintech/data/relay/clientlike.py +45 -0
  54. xfintech/data/relay/tests/test_class_relayclient_all.py +484 -0
  55. xfintech/data/relay/tests/test_class_relayclientlike_all.py +500 -0
  56. xfintech/data/source/__init__.py +7 -0
  57. xfintech/data/source/baostock/__init__.py +21 -0
  58. xfintech/data/source/baostock/job/__init__.py +5 -0
  59. xfintech/data/source/baostock/job/job.py +217 -0
  60. xfintech/data/source/baostock/job/tests/__init__.py +0 -0
  61. xfintech/data/source/baostock/job/tests/test_class_baostockjob_all.py +547 -0
  62. xfintech/data/source/baostock/session/__init__.py +8 -0
  63. xfintech/data/source/baostock/session/relay.py +223 -0
  64. xfintech/data/source/baostock/session/session.py +241 -0
  65. xfintech/data/source/baostock/session/tests/__init__.py +0 -0
  66. xfintech/data/source/baostock/session/tests/test_class_relay_all.py +694 -0
  67. xfintech/data/source/baostock/session/tests/test_class_session_all.py +505 -0
  68. xfintech/data/source/baostock/stock/__init__.py +0 -0
  69. xfintech/data/source/baostock/stock/hs300stock/__init__.py +3 -0
  70. xfintech/data/source/baostock/stock/hs300stock/constant.py +49 -0
  71. xfintech/data/source/baostock/stock/hs300stock/hs300stock.py +133 -0
  72. xfintech/data/source/baostock/stock/hs300stock/tests/__init__.py +1 -0
  73. xfintech/data/source/baostock/stock/hs300stock/tests/test_class_hs300index_all.py +413 -0
  74. xfintech/data/source/baostock/stock/minuteline/__init__.py +19 -0
  75. xfintech/data/source/baostock/stock/minuteline/constant.py +89 -0
  76. xfintech/data/source/baostock/stock/minuteline/minuteline.py +163 -0
  77. xfintech/data/source/baostock/stock/minuteline/tests/__init__.py +0 -0
  78. xfintech/data/source/baostock/stock/minuteline/tests/test_class_minuteline_all.py +582 -0
  79. xfintech/data/source/baostock/stock/stock/__init__.py +19 -0
  80. xfintech/data/source/baostock/stock/stock/constant.py +55 -0
  81. xfintech/data/source/baostock/stock/stock/stock.py +149 -0
  82. xfintech/data/source/baostock/stock/stock/tests/__init__.py +0 -0
  83. xfintech/data/source/baostock/stock/stock/tests/test_class_stock_all.py +508 -0
  84. xfintech/data/source/baostock/stock/stockinfo/__init__.py +5 -0
  85. xfintech/data/source/baostock/stock/stockinfo/constant.py +66 -0
  86. xfintech/data/source/baostock/stock/stockinfo/stockinfo.py +176 -0
  87. xfintech/data/source/baostock/stock/stockinfo/tests/__init__.py +1 -0
  88. xfintech/data/source/baostock/stock/stockinfo/tests/test_class_stockinfo_all.py +617 -0
  89. xfintech/data/source/baostock/stock/sz50stock/__init__.py +3 -0
  90. xfintech/data/source/baostock/stock/sz50stock/constant.py +49 -0
  91. xfintech/data/source/baostock/stock/sz50stock/sz50stock.py +133 -0
  92. xfintech/data/source/baostock/stock/sz50stock/tests/__init__.py +1 -0
  93. xfintech/data/source/baostock/stock/sz50stock/tests/test_class_sz50stock_all.py +397 -0
  94. xfintech/data/source/baostock/stock/tradedate/__init__.py +19 -0
  95. xfintech/data/source/baostock/stock/tradedate/constant.py +72 -0
  96. xfintech/data/source/baostock/stock/tradedate/tests/__init__.py +0 -0
  97. xfintech/data/source/baostock/stock/tradedate/tests/test_class_tradedate_all.py +695 -0
  98. xfintech/data/source/baostock/stock/tradedate/tradedate.py +208 -0
  99. xfintech/data/source/baostock/stock/zz500stock/__init__.py +3 -0
  100. xfintech/data/source/baostock/stock/zz500stock/constant.py +55 -0
  101. xfintech/data/source/baostock/stock/zz500stock/tests/__init__.py +1 -0
  102. xfintech/data/source/baostock/stock/zz500stock/tests/test_class_zz500stock_all.py +421 -0
  103. xfintech/data/source/baostock/stock/zz500stock/zz500stock.py +133 -0
  104. xfintech/data/source/tushare/__init__.py +61 -0
  105. xfintech/data/source/tushare/job/__init__.py +5 -0
  106. xfintech/data/source/tushare/job/job.py +257 -0
  107. xfintech/data/source/tushare/job/tests/test_class_tusharejob_all.py +589 -0
  108. xfintech/data/source/tushare/session/__init__.py +5 -0
  109. xfintech/data/source/tushare/session/relay.py +231 -0
  110. xfintech/data/source/tushare/session/session.py +239 -0
  111. xfintech/data/source/tushare/session/tests/test_class_relay_all.py +719 -0
  112. xfintech/data/source/tushare/session/tests/test_class_session_all.py +705 -0
  113. xfintech/data/source/tushare/stock/__init__.py +55 -0
  114. xfintech/data/source/tushare/stock/adjfactor/__init__.py +19 -0
  115. xfintech/data/source/tushare/stock/adjfactor/adjfactor.py +150 -0
  116. xfintech/data/source/tushare/stock/adjfactor/constant.py +71 -0
  117. xfintech/data/source/tushare/stock/adjfactor/tests/__init__.py +0 -0
  118. xfintech/data/source/tushare/stock/adjfactor/tests/test_class_adjfactor_all.py +372 -0
  119. xfintech/data/source/tushare/stock/capflow/__init__.py +19 -0
  120. xfintech/data/source/tushare/stock/capflow/capflow.py +171 -0
  121. xfintech/data/source/tushare/stock/capflow/constant.py +105 -0
  122. xfintech/data/source/tushare/stock/capflow/tests/__init__.py +0 -0
  123. xfintech/data/source/tushare/stock/capflow/tests/test_class_capflow_all.py +589 -0
  124. xfintech/data/source/tushare/stock/capflowdc/__init__.py +19 -0
  125. xfintech/data/source/tushare/stock/capflowdc/capflowdc.py +167 -0
  126. xfintech/data/source/tushare/stock/capflowdc/constant.py +95 -0
  127. xfintech/data/source/tushare/stock/capflowdc/tests/__init__.py +0 -0
  128. xfintech/data/source/tushare/stock/capflowdc/tests/test_class_capflowdc_all.py +814 -0
  129. xfintech/data/source/tushare/stock/capflowths/__init__.py +19 -0
  130. xfintech/data/source/tushare/stock/capflowths/capflowths.py +173 -0
  131. xfintech/data/source/tushare/stock/capflowths/constant.py +92 -0
  132. xfintech/data/source/tushare/stock/capflowths/tests/__init__.py +0 -0
  133. xfintech/data/source/tushare/stock/capflowths/tests/test_class_capflowths_all.py +551 -0
  134. xfintech/data/source/tushare/stock/company/__init__.py +19 -0
  135. xfintech/data/source/tushare/stock/company/company.py +188 -0
  136. xfintech/data/source/tushare/stock/company/constant.py +92 -0
  137. xfintech/data/source/tushare/stock/company/tests/__init__.py +1 -0
  138. xfintech/data/source/tushare/stock/company/tests/test_class_company_all.py +829 -0
  139. xfintech/data/source/tushare/stock/companybusiness/__init__.py +21 -0
  140. xfintech/data/source/tushare/stock/companybusiness/companybusiness.py +183 -0
  141. xfintech/data/source/tushare/stock/companybusiness/constant.py +91 -0
  142. xfintech/data/source/tushare/stock/companybusiness/tests/__init__.py +0 -0
  143. xfintech/data/source/tushare/stock/companybusiness/tests/test_class_companybusiness_all.py +633 -0
  144. xfintech/data/source/tushare/stock/companycashflow/__init__.py +21 -0
  145. xfintech/data/source/tushare/stock/companycashflow/companycashflow.py +277 -0
  146. xfintech/data/source/tushare/stock/companycashflow/constant.py +293 -0
  147. xfintech/data/source/tushare/stock/companycashflow/tests/__init__.py +0 -0
  148. xfintech/data/source/tushare/stock/companycashflow/tests/test_class_companycashflow_all.py +619 -0
  149. xfintech/data/source/tushare/stock/companydebt/__init__.py +19 -0
  150. xfintech/data/source/tushare/stock/companydebt/companydebt.py +339 -0
  151. xfintech/data/source/tushare/stock/companydebt/constant.py +403 -0
  152. xfintech/data/source/tushare/stock/companydebt/tests/__init__.py +0 -0
  153. xfintech/data/source/tushare/stock/companydebt/tests/test_class_companydebt_all.py +655 -0
  154. xfintech/data/source/tushare/stock/companyoverview/__init__.py +21 -0
  155. xfintech/data/source/tushare/stock/companyoverview/companyoverview.py +214 -0
  156. xfintech/data/source/tushare/stock/companyoverview/constant.py +152 -0
  157. xfintech/data/source/tushare/stock/companyoverview/tests/__init__.py +0 -0
  158. xfintech/data/source/tushare/stock/companyoverview/tests/test_class_companyoverview_all.py +647 -0
  159. xfintech/data/source/tushare/stock/companyprofit/__init__.py +21 -0
  160. xfintech/data/source/tushare/stock/companyprofit/companyprofit.py +272 -0
  161. xfintech/data/source/tushare/stock/companyprofit/constant.py +259 -0
  162. xfintech/data/source/tushare/stock/companyprofit/tests/__init__.py +0 -0
  163. xfintech/data/source/tushare/stock/companyprofit/tests/test_class_companyprofit_all.py +635 -0
  164. xfintech/data/source/tushare/stock/conceptcapflowdc/__init__.py +21 -0
  165. xfintech/data/source/tushare/stock/conceptcapflowdc/conceptcapflowdc.py +175 -0
  166. xfintech/data/source/tushare/stock/conceptcapflowdc/constant.py +106 -0
  167. xfintech/data/source/tushare/stock/conceptcapflowdc/tests/__init__.py +0 -0
  168. xfintech/data/source/tushare/stock/conceptcapflowdc/tests/test_class_conceptcapflowdc_all.py +568 -0
  169. xfintech/data/source/tushare/stock/conceptcapflowths/__init__.py +21 -0
  170. xfintech/data/source/tushare/stock/conceptcapflowths/conceptcapflowths.py +188 -0
  171. xfintech/data/source/tushare/stock/conceptcapflowths/constant.py +89 -0
  172. xfintech/data/source/tushare/stock/conceptcapflowths/tests/__init__.py +0 -0
  173. xfintech/data/source/tushare/stock/conceptcapflowths/tests/test_class_conceptcapflowths_all.py +516 -0
  174. xfintech/data/source/tushare/stock/dayline/__init__.py +19 -0
  175. xfintech/data/source/tushare/stock/dayline/constant.py +87 -0
  176. xfintech/data/source/tushare/stock/dayline/dayline.py +177 -0
  177. xfintech/data/source/tushare/stock/dayline/tests/__init__.py +0 -0
  178. xfintech/data/source/tushare/stock/dayline/tests/test_class_dayline_all.py +585 -0
  179. xfintech/data/source/tushare/stock/industrycapflowths/__init__.py +21 -0
  180. xfintech/data/source/tushare/stock/industrycapflowths/constant.py +89 -0
  181. xfintech/data/source/tushare/stock/industrycapflowths/industrycapflowths.py +192 -0
  182. xfintech/data/source/tushare/stock/industrycapflowths/tests/__init__.py +0 -0
  183. xfintech/data/source/tushare/stock/industrycapflowths/tests/test_class_industrycapflowths_all.py +683 -0
  184. xfintech/data/source/tushare/stock/marketindexcapflowdc/__init__.py +21 -0
  185. xfintech/data/source/tushare/stock/marketindexcapflowdc/constant.py +90 -0
  186. xfintech/data/source/tushare/stock/marketindexcapflowdc/marketindexcapflowdc.py +173 -0
  187. xfintech/data/source/tushare/stock/marketindexcapflowdc/tests/__init__.py +0 -0
  188. xfintech/data/source/tushare/stock/marketindexcapflowdc/tests/test_class_marketindexcapflowdc_all.py +793 -0
  189. xfintech/data/source/tushare/stock/monthline/__init__.py +19 -0
  190. xfintech/data/source/tushare/stock/monthline/constant.py +87 -0
  191. xfintech/data/source/tushare/stock/monthline/monthline.py +180 -0
  192. xfintech/data/source/tushare/stock/monthline/tests/__init__.py +0 -0
  193. xfintech/data/source/tushare/stock/monthline/tests/test_class_monthline_all.py +574 -0
  194. xfintech/data/source/tushare/stock/stock/__init__.py +19 -0
  195. xfintech/data/source/tushare/stock/stock/constant.py +105 -0
  196. xfintech/data/source/tushare/stock/stock/stock.py +193 -0
  197. xfintech/data/source/tushare/stock/stock/tests/__init__.py +0 -0
  198. xfintech/data/source/tushare/stock/stock/tests/test_class_stock_all.py +788 -0
  199. xfintech/data/source/tushare/stock/stockdividend/__init__.py +21 -0
  200. xfintech/data/source/tushare/stock/stockdividend/constant.py +111 -0
  201. xfintech/data/source/tushare/stock/stockdividend/stockdividend.py +180 -0
  202. xfintech/data/source/tushare/stock/stockdividend/tests/__init__.py +0 -0
  203. xfintech/data/source/tushare/stock/stockdividend/tests/test_class_stockdividend_all.py +725 -0
  204. xfintech/data/source/tushare/stock/stockinfo/__init__.py +19 -0
  205. xfintech/data/source/tushare/stock/stockinfo/constant.py +104 -0
  206. xfintech/data/source/tushare/stock/stockinfo/stockinfo.py +208 -0
  207. xfintech/data/source/tushare/stock/stockinfo/tests/__init__.py +0 -0
  208. xfintech/data/source/tushare/stock/stockinfo/tests/test_class_stockinfo_all.py +881 -0
  209. xfintech/data/source/tushare/stock/stockipo/__init__.py +19 -0
  210. xfintech/data/source/tushare/stock/stockipo/constant.py +90 -0
  211. xfintech/data/source/tushare/stock/stockipo/stockipo.py +234 -0
  212. xfintech/data/source/tushare/stock/stockipo/tests/__init__.py +1 -0
  213. xfintech/data/source/tushare/stock/stockipo/tests/test_class_stockipo_all.py +750 -0
  214. xfintech/data/source/tushare/stock/stockpledge/__init__.py +19 -0
  215. xfintech/data/source/tushare/stock/stockpledge/constant.py +72 -0
  216. xfintech/data/source/tushare/stock/stockpledge/stockpledge.py +158 -0
  217. xfintech/data/source/tushare/stock/stockpledge/tests/__init__.py +0 -0
  218. xfintech/data/source/tushare/stock/stockpledge/tests/test_class_stockpledge_all.py +664 -0
  219. xfintech/data/source/tushare/stock/stockpledgedetail/__init__.py +21 -0
  220. xfintech/data/source/tushare/stock/stockpledgedetail/constant.py +85 -0
  221. xfintech/data/source/tushare/stock/stockpledgedetail/stockpledgedetail.py +171 -0
  222. xfintech/data/source/tushare/stock/stockpledgedetail/tests/__init__.py +0 -0
  223. xfintech/data/source/tushare/stock/stockpledgedetail/tests/test_class_stockpledgedetail_all.py +112 -0
  224. xfintech/data/source/tushare/stock/stockst/__init__.py +19 -0
  225. xfintech/data/source/tushare/stock/stockst/constant.py +80 -0
  226. xfintech/data/source/tushare/stock/stockst/stockst.py +189 -0
  227. xfintech/data/source/tushare/stock/stockst/tests/__init__.py +0 -0
  228. xfintech/data/source/tushare/stock/stockst/tests/test_class_stockst_all.py +693 -0
  229. xfintech/data/source/tushare/stock/stocksuspend/__init__.py +21 -0
  230. xfintech/data/source/tushare/stock/stocksuspend/constant.py +75 -0
  231. xfintech/data/source/tushare/stock/stocksuspend/stocksuspend.py +151 -0
  232. xfintech/data/source/tushare/stock/stocksuspend/tests/__init__.py +0 -0
  233. xfintech/data/source/tushare/stock/stocksuspend/tests/test_class_stocksuspend_all.py +626 -0
  234. xfintech/data/source/tushare/stock/techindex/__init__.py +19 -0
  235. xfintech/data/source/tushare/stock/techindex/constant.py +600 -0
  236. xfintech/data/source/tushare/stock/techindex/techindex.py +314 -0
  237. xfintech/data/source/tushare/stock/techindex/tests/__init__.py +0 -0
  238. xfintech/data/source/tushare/stock/techindex/tests/test_class_techindex_all.py +576 -0
  239. xfintech/data/source/tushare/stock/tradedate/__init__.py +19 -0
  240. xfintech/data/source/tushare/stock/tradedate/constant.py +93 -0
  241. xfintech/data/source/tushare/stock/tradedate/tests/__init__.py +0 -0
  242. xfintech/data/source/tushare/stock/tradedate/tests/test_class_tradedate_all.py +947 -0
  243. xfintech/data/source/tushare/stock/tradedate/tradedate.py +234 -0
  244. xfintech/data/source/tushare/stock/weekline/__init__.py +19 -0
  245. xfintech/data/source/tushare/stock/weekline/constant.py +87 -0
  246. xfintech/data/source/tushare/stock/weekline/tests/__init__.py +0 -0
  247. xfintech/data/source/tushare/stock/weekline/tests/test_class_weekline_all.py +575 -0
  248. xfintech/data/source/tushare/stock/weekline/weekline.py +182 -0
  249. xfintech/fabric/__init__.py +18 -0
  250. xfintech/fabric/column/__init__.py +7 -0
  251. xfintech/fabric/column/info.py +202 -0
  252. xfintech/fabric/column/kind.py +102 -0
  253. xfintech/fabric/column/tests/__init__.py +0 -0
  254. xfintech/fabric/column/tests/test_class_info_all.py +207 -0
  255. xfintech/fabric/column/tests/test_class_kind_all.py +80 -0
  256. xfintech/fabric/table/__init__.py +5 -0
  257. xfintech/fabric/table/info.py +263 -0
  258. xfintech/fabric/table/tests/__init__.py +0 -0
  259. xfintech/fabric/table/tests/test_class_info_all.py +547 -0
  260. xfintech/serde/__init__.py +35 -0
  261. xfintech/serde/common/__init__.py +9 -0
  262. xfintech/serde/common/dataformat.py +78 -0
  263. xfintech/serde/common/deserialiserlike.py +38 -0
  264. xfintech/serde/common/error.py +182 -0
  265. xfintech/serde/common/serialiserlike.py +38 -0
  266. xfintech/serde/common/tests/__init__.py +1 -0
  267. xfintech/serde/common/tests/test_class_dataformat_all.py +694 -0
  268. xfintech/serde/common/tests/test_class_deserialiserlike_all.py +500 -0
  269. xfintech/serde/common/tests/test_class_errors_all.py +518 -0
  270. xfintech/serde/common/tests/test_class_serialiserlike_all.py +401 -0
  271. xfintech/serde/deserialiser/__init__.py +7 -0
  272. xfintech/serde/deserialiser/pandas.py +113 -0
  273. xfintech/serde/deserialiser/python.py +68 -0
  274. xfintech/serde/deserialiser/tests/__init__.py +1 -0
  275. xfintech/serde/deserialiser/tests/test_class_pandasdeserialiser_all.py +503 -0
  276. xfintech/serde/deserialiser/tests/test_class_pythondeserialiser_all.py +570 -0
  277. xfintech/serde/serialiser/__init__.py +7 -0
  278. xfintech/serde/serialiser/pandas.py +116 -0
  279. xfintech/serde/serialiser/python.py +71 -0
  280. xfintech/serde/serialiser/tests/__init__.py +1 -0
  281. xfintech/serde/serialiser/tests/test_class_pandasserialiser_all.py +474 -0
  282. xfintech/serde/serialiser/tests/test_class_pythonserialiser_all.py +508 -0
@@ -0,0 +1,655 @@
1
+ """
2
+ Comprehensive test suite for CompanyDebt class
3
+ Tests cover initialization, transformation, execution, and integration scenarios
4
+ """
5
+
6
+ import pandas as pd
7
+ import pytest
8
+
9
+ from xfintech.data.source.tushare.stock.companydebt import CompanyDebt
10
+ from xfintech.data.source.tushare.stock.companydebt.constant import (
11
+ KEY,
12
+ NAME,
13
+ PAGINATE,
14
+ SOURCE,
15
+ TARGET,
16
+ )
17
+
18
+ # ============================================================================
19
+ # Test Fixtures
20
+ # ============================================================================
21
+
22
+
23
+ class FakeConnection:
24
+ """Fake Tushare connection for testing"""
25
+
26
+ def __init__(self, frame: pd.DataFrame):
27
+ self.frame = frame
28
+
29
+ def balancesheet_vip(self, **kwargs):
30
+ """Mock balancesheet_vip API call"""
31
+ return self.frame
32
+
33
+
34
+ class FakeSession:
35
+ """Fake session for testing"""
36
+
37
+ def __init__(self, connection: FakeConnection):
38
+ self.connection = connection
39
+
40
+
41
+ @pytest.fixture
42
+ def mock_session():
43
+ """Create a mock session with empty data"""
44
+ fake_conn = FakeConnection(frame=pd.DataFrame())
45
+ return FakeSession(fake_conn)
46
+
47
+
48
+ @pytest.fixture
49
+ def sample_source_data():
50
+ """Sample balance sheet data in Tushare format"""
51
+ return pd.DataFrame(
52
+ {
53
+ "ts_code": ["000001.SZ", "000001.SZ", "000002.SZ"],
54
+ "ann_date": ["20200430", "20201031", "20200430"],
55
+ "f_ann_date": ["20200430", "20201031", "20200430"],
56
+ "end_date": ["20200331", "20200930", "20200331"],
57
+ "report_type": ["1", "1", "1"],
58
+ "comp_type": ["2", "2", "1"],
59
+ "end_type": ["Q1", "Q3", "Q1"],
60
+ "total_assets": ["2000000.50", "2100000.75", "500000.25"],
61
+ "total_liab": ["1500000.30", "1550000.40", "300000.15"],
62
+ "total_hldr_eqy_inc_min_int": ["500000.20", "550000.35", "200000.10"],
63
+ "money_cap": ["100000.00", "110000.00", "50000.00"],
64
+ "accounts_receiv": ["80000.50", "85000.75", "30000.25"],
65
+ "inventories": ["60000.25", "65000.50", "25000.10"],
66
+ "fix_assets": ["400000.00", "420000.00", "150000.00"],
67
+ "update_flag": ["0", "0", "0"],
68
+ }
69
+ )
70
+
71
+
72
+ # ============================================================================
73
+ # Initialization Tests
74
+ # ============================================================================
75
+
76
+
77
+ def test_companydebt_init_basic(mock_session):
78
+ """Test basic initialization with required session"""
79
+ debt = CompanyDebt(session=mock_session)
80
+ assert debt.name == NAME
81
+ assert debt.key == KEY
82
+ assert debt.source == SOURCE
83
+ assert debt.target == TARGET
84
+ assert debt.paginate == PAGINATE
85
+
86
+
87
+ def test_companydebt_init_with_params_dict(mock_session):
88
+ """Test initialization with params as dict"""
89
+ params = {"ts_code": "000001.SZ", "start_date": "20200101", "end_date": "20201231"}
90
+ debt = CompanyDebt(session=mock_session, params=params)
91
+ assert debt.params.get("ts_code") == "000001.SZ"
92
+ assert debt.params.get("start_date") == "20200101"
93
+ assert debt.params.get("end_date") == "20201231"
94
+
95
+
96
+ def test_companydebt_init_with_params_object(mock_session):
97
+ """Test initialization with params as Params object"""
98
+ from xfintech.data.common.params import Params
99
+
100
+ params = Params(ts_code="000001.SZ", start_date="20200101")
101
+ debt = CompanyDebt(session=mock_session, params=params)
102
+ assert debt.params.get("ts_code") == "000001.SZ"
103
+
104
+
105
+ def test_companydebt_init_with_period_param(mock_session):
106
+ """Test initialization with period parameter"""
107
+ params = {"ts_code": "000001.SZ", "period": "20201231"}
108
+ debt = CompanyDebt(session=mock_session, params=params)
109
+ assert debt.params.get("period") == "20201231"
110
+
111
+
112
+ def test_companydebt_init_with_cache_bool_true(mock_session):
113
+ """Test initialization with cache enabled"""
114
+ debt = CompanyDebt(session=mock_session, cache=True)
115
+ assert debt.cache is not None
116
+
117
+
118
+ def test_companydebt_init_with_cache_bool_false(mock_session):
119
+ """Test initialization with cache disabled"""
120
+ debt = CompanyDebt(session=mock_session, cache=False)
121
+ assert debt.cache is None
122
+
123
+
124
+ def test_companydebt_init_with_cache_dict(mock_session):
125
+ """Test initialization with cache config dict"""
126
+ cache_config = {"path": "/tmp/cache", "key": "test"}
127
+ debt = CompanyDebt(session=mock_session, cache=cache_config)
128
+ assert debt.cache is not None
129
+
130
+
131
+ def test_companydebt_init_default_paginate_limit(mock_session):
132
+ """Test that default pagination limit is set correctly"""
133
+ debt = CompanyDebt(session=mock_session)
134
+ assert debt.paginate.pagesize == 1000
135
+ assert debt.paginate.pagelimit == 1000
136
+
137
+
138
+ def test_companydebt_init_with_all_params(mock_session):
139
+ """Test initialization with all parameters"""
140
+ params = {"ts_code": "000001.SZ", "start_date": "20200101", "end_date": "20201231"}
141
+ coolant = {"interval": 0.5}
142
+ retry = {"max_attempts": 3}
143
+ cache = True
144
+
145
+ debt = CompanyDebt(session=mock_session, params=params, coolant=coolant, retry=retry, cache=cache)
146
+ assert debt.params.get("ts_code") == "000001.SZ"
147
+ assert debt.cache is not None
148
+
149
+
150
+ def test_companydebt_constants():
151
+ """Test that constants are correctly defined"""
152
+ assert NAME == "companydebt"
153
+ assert KEY == "/tushare/companydebt"
154
+ assert SOURCE.name == "balancesheet_vip"
155
+ assert TARGET.name == "companydebt"
156
+ assert PAGINATE.pagesize == 1000
157
+
158
+
159
+ # ============================================================================
160
+ # Transform Tests
161
+ # ============================================================================
162
+
163
+
164
+ def test_companydebt_transform_basic(sample_source_data):
165
+ """Test basic transformation of balance sheet data"""
166
+ fake_conn = FakeConnection(frame=sample_source_data)
167
+ session = FakeSession(fake_conn)
168
+ debt = CompanyDebt(session=session, params={"ts_code": "000001.SZ"})
169
+
170
+ result = debt.transform(sample_source_data)
171
+
172
+ assert len(result) == 3
173
+ assert "code" in result.columns
174
+ assert "date" in result.columns
175
+ assert "datecode" in result.columns
176
+
177
+
178
+ def test_companydebt_transform_code_mapping(sample_source_data):
179
+ """Test that ts_code is correctly mapped to code"""
180
+ fake_conn = FakeConnection(frame=sample_source_data)
181
+ session = FakeSession(fake_conn)
182
+ debt = CompanyDebt(session=session, params={"ts_code": "000001.SZ"})
183
+
184
+ result = debt.transform(sample_source_data)
185
+
186
+ assert result.iloc[0]["code"] == "000001.SZ"
187
+ assert result.iloc[2]["code"] == "000002.SZ"
188
+
189
+
190
+ def test_companydebt_transform_date_format(sample_source_data):
191
+ """Test that dates are properly formatted"""
192
+ fake_conn = FakeConnection(frame=sample_source_data)
193
+ session = FakeSession(fake_conn)
194
+ debt = CompanyDebt(session=session, params={"ts_code": "000001.SZ"})
195
+
196
+ result = debt.transform(sample_source_data)
197
+
198
+ assert pd.api.types.is_datetime64_any_dtype(result["date"]) is False
199
+ assert result.iloc[0]["date"] == "2020-03-31"
200
+
201
+
202
+ def test_companydebt_transform_datecode_preserved(sample_source_data):
203
+ """Test that datecode is correctly created from end_date"""
204
+ fake_conn = FakeConnection(frame=sample_source_data)
205
+ session = FakeSession(fake_conn)
206
+ debt = CompanyDebt(session=session, params={"ts_code": "000001.SZ"})
207
+
208
+ result = debt.transform(sample_source_data)
209
+
210
+ assert result.iloc[0]["datecode"] == "20200331"
211
+ assert result.iloc[1]["datecode"] == "20200930"
212
+
213
+
214
+ def test_companydebt_transform_numeric_conversions(sample_source_data):
215
+ """Test that numeric fields are properly converted"""
216
+ fake_conn = FakeConnection(frame=sample_source_data)
217
+ session = FakeSession(fake_conn)
218
+ debt = CompanyDebt(session=session, params={"ts_code": "000001.SZ"})
219
+
220
+ result = debt.transform(sample_source_data)
221
+
222
+ assert result.iloc[0]["total_assets"] == 2000000.50
223
+ assert result.iloc[0]["total_liab"] == 1500000.30
224
+ assert pd.api.types.is_numeric_dtype(result["total_assets"])
225
+
226
+
227
+ def test_companydebt_transform_string_fields(sample_source_data):
228
+ """Test that string fields are properly converted"""
229
+ fake_conn = FakeConnection(frame=sample_source_data)
230
+ session = FakeSession(fake_conn)
231
+ debt = CompanyDebt(session=session, params={"ts_code": "000001.SZ"})
232
+
233
+ result = debt.transform(sample_source_data)
234
+
235
+ assert result.iloc[0]["report_type"] == "1"
236
+ assert result.iloc[0]["comp_type"] == "2"
237
+ assert result.iloc[0]["update_flag"] == "0"
238
+
239
+
240
+ def test_companydebt_transform_empty_dataframe():
241
+ """Test transformation with empty dataframe"""
242
+ fake_conn = FakeConnection(frame=pd.DataFrame())
243
+ session = FakeSession(fake_conn)
244
+ debt = CompanyDebt(session=session, params={"ts_code": "000001.SZ"})
245
+
246
+ result = debt.transform(pd.DataFrame())
247
+
248
+ assert isinstance(result, pd.DataFrame)
249
+ assert result.empty
250
+ assert len(result.columns) == len(TARGET.list_column_names())
251
+
252
+
253
+ def test_companydebt_transform_none_input():
254
+ """Test transformation with None input"""
255
+ fake_conn = FakeConnection(frame=pd.DataFrame())
256
+ session = FakeSession(fake_conn)
257
+ debt = CompanyDebt(session=session, params={"ts_code": "000001.SZ"})
258
+
259
+ result = debt.transform(None)
260
+
261
+ assert isinstance(result, pd.DataFrame)
262
+ assert result.empty
263
+
264
+
265
+ def test_companydebt_transform_handles_invalid_dates():
266
+ """Test that invalid dates are handled gracefully"""
267
+ data = pd.DataFrame(
268
+ {
269
+ "ts_code": ["000001.SZ"],
270
+ "ann_date": ["invalid"],
271
+ "f_ann_date": ["20200430"],
272
+ "end_date": ["20200331"],
273
+ "report_type": ["1"],
274
+ "comp_type": ["1"],
275
+ "end_type": ["Q1"],
276
+ "update_flag": ["0"],
277
+ }
278
+ )
279
+
280
+ fake_conn = FakeConnection(frame=data)
281
+ session = FakeSession(fake_conn)
282
+ debt = CompanyDebt(session=session, params={"ts_code": "000001.SZ"})
283
+
284
+ result = debt.transform(data)
285
+
286
+ assert len(result) == 1
287
+ assert pd.isna(result.iloc[0]["ann_date"])
288
+
289
+
290
+ def test_companydebt_transform_removes_duplicates(sample_source_data):
291
+ """Test that duplicate rows are removed"""
292
+ # Create data with duplicates
293
+ data = pd.concat([sample_source_data, sample_source_data.iloc[[0]]], ignore_index=True)
294
+
295
+ fake_conn = FakeConnection(frame=data)
296
+ session = FakeSession(fake_conn)
297
+ debt = CompanyDebt(session=session, params={"ts_code": "000001.SZ"})
298
+
299
+ result = debt.transform(data)
300
+
301
+ # Should have 3 unique rows, not 4
302
+ assert len(result) == 3
303
+
304
+
305
+ def test_companydebt_transform_sorts_by_code_and_date(sample_source_data):
306
+ """Test that output is sorted by code and date"""
307
+ fake_conn = FakeConnection(frame=sample_source_data)
308
+ session = FakeSession(fake_conn)
309
+ debt = CompanyDebt(session=session, params={"ts_code": "000001.SZ"})
310
+
311
+ result = debt.transform(sample_source_data)
312
+
313
+ # Check first row is 000001.SZ, 2020-03-31
314
+ assert result.iloc[0]["code"] == "000001.SZ"
315
+ assert result.iloc[0]["date"] == "2020-03-31"
316
+ # Check last row is 000002.SZ
317
+ assert result.iloc[2]["code"] == "000002.SZ"
318
+
319
+
320
+ def test_companydebt_transform_resets_index():
321
+ """Test that index is reset after transformation"""
322
+ data = pd.DataFrame(
323
+ {
324
+ "ts_code": ["000001.SZ", "000002.SZ"],
325
+ "ann_date": ["20200430", "20200430"],
326
+ "f_ann_date": ["20200430", "20200430"],
327
+ "end_date": ["20200331", "20200331"],
328
+ "report_type": ["1", "1"],
329
+ "comp_type": ["1", "1"],
330
+ "end_type": ["Q1", "Q1"],
331
+ "update_flag": ["0", "0"],
332
+ },
333
+ index=[5, 10],
334
+ )
335
+
336
+ fake_conn = FakeConnection(frame=data)
337
+ session = FakeSession(fake_conn)
338
+ debt = CompanyDebt(session=session, params={"ts_code": "000001.SZ"})
339
+
340
+ result = debt.transform(data)
341
+
342
+ assert result.index.tolist() == [0, 1]
343
+
344
+
345
+ def test_companydebt_transform_only_target_columns(sample_source_data):
346
+ """Test that only target columns are in output"""
347
+ fake_conn = FakeConnection(frame=sample_source_data)
348
+ session = FakeSession(fake_conn)
349
+ debt = CompanyDebt(session=session, params={"ts_code": "000001.SZ"})
350
+
351
+ result = debt.transform(sample_source_data)
352
+
353
+ expected_cols = set(TARGET.list_column_names())
354
+ actual_cols = set(result.columns)
355
+
356
+ assert actual_cols == expected_cols
357
+
358
+
359
+ # ============================================================================
360
+ # Run Method Tests
361
+ # ============================================================================
362
+
363
+
364
+ def test_companydebt_run_with_cache_hit(sample_source_data):
365
+ """Test that run() returns cached data when available"""
366
+ fake_conn = FakeConnection(frame=sample_source_data)
367
+ session = FakeSession(fake_conn)
368
+ debt = CompanyDebt(session=session, params={"ts_code": "000001.SZ"}, cache=True)
369
+
370
+ # First run should fetch and cache
371
+ result1 = debt.run()
372
+
373
+ # Second run should return cached data
374
+ result2 = debt.run()
375
+
376
+ pd.testing.assert_frame_equal(result1, result2)
377
+
378
+
379
+ def test_companydebt_run_basic_date_range(sample_source_data):
380
+ """Test run() with date range parameters"""
381
+ fake_conn = FakeConnection(frame=sample_source_data)
382
+ session = FakeSession(fake_conn)
383
+ debt = CompanyDebt(
384
+ session=session,
385
+ params={"ts_code": "000001.SZ", "start_date": "20200101", "end_date": "20201231"},
386
+ )
387
+
388
+ result = debt.run()
389
+
390
+ assert isinstance(result, pd.DataFrame)
391
+ assert len(result) > 0
392
+
393
+
394
+ def test_companydebt_run_with_datetime_params(sample_source_data):
395
+ """Test run() with datetime objects as parameters"""
396
+ from datetime import datetime
397
+
398
+ fake_conn = FakeConnection(frame=sample_source_data)
399
+ session = FakeSession(fake_conn)
400
+ debt = CompanyDebt(
401
+ session=session,
402
+ params={
403
+ "ts_code": "000001.SZ",
404
+ "start_date": datetime(2020, 1, 1),
405
+ "end_date": datetime(2020, 12, 31),
406
+ },
407
+ )
408
+
409
+ result = debt.run()
410
+
411
+ assert isinstance(result, pd.DataFrame)
412
+
413
+
414
+ def test_companydebt_run_adds_fields_param(sample_source_data):
415
+ """Test that run() adds fields parameter if not provided"""
416
+ fake_conn = FakeConnection(frame=sample_source_data)
417
+ session = FakeSession(fake_conn)
418
+ debt = CompanyDebt(session=session, params={"ts_code": "000001.SZ"})
419
+
420
+ # Monkey patch _fetchall to capture params
421
+ debt._fetchall
422
+ captured_params = {}
423
+
424
+ def mock_fetchall(api, **kwargs):
425
+ captured_params.update(kwargs)
426
+ return sample_source_data
427
+
428
+ debt._fetchall = mock_fetchall
429
+ debt.run()
430
+
431
+ assert "fields" in captured_params
432
+ assert len(captured_params["fields"]) > 0
433
+
434
+
435
+ def test_companydebt_run_sets_cache(sample_source_data):
436
+ """Test that run() saves result to cache"""
437
+ fake_conn = FakeConnection(frame=sample_source_data)
438
+ session = FakeSession(fake_conn)
439
+ debt = CompanyDebt(session=session, params={"ts_code": "000001.SZ"}, cache=True)
440
+
441
+ result = debt.run()
442
+
443
+ # Cache should be set after run
444
+ cached = debt._load_cache()
445
+ assert cached is not None
446
+ pd.testing.assert_frame_equal(result, cached)
447
+
448
+
449
+ def test_companydebt_run_calls_transform(sample_source_data):
450
+ """Test that run() calls transform method"""
451
+ fake_conn = FakeConnection(frame=sample_source_data)
452
+ session = FakeSession(fake_conn)
453
+ debt = CompanyDebt(session=session, params={"ts_code": "000001.SZ"})
454
+
455
+ # Monkey patch transform to track if it was called
456
+ original_transform = debt.transform
457
+ transform_called = {"called": False}
458
+
459
+ def mock_transform(data):
460
+ transform_called["called"] = True
461
+ return original_transform(data)
462
+
463
+ debt.transform = mock_transform
464
+ debt.run()
465
+
466
+ assert transform_called["called"] is True
467
+
468
+
469
+ def test_companydebt_run_uses_balancesheet_vip_api(sample_source_data):
470
+ """Test that run() uses balancesheet_vip API"""
471
+ fake_conn = FakeConnection(frame=sample_source_data)
472
+ session = FakeSession(fake_conn)
473
+ debt = CompanyDebt(session=session, params={"ts_code": "000001.SZ"})
474
+
475
+ # Monkey patch _fetchall to capture API
476
+ captured_api = {"api": None}
477
+
478
+ def mock_fetchall(api, **kwargs):
479
+ captured_api["api"] = api
480
+ return sample_source_data
481
+
482
+ debt._fetchall = mock_fetchall
483
+ debt.run()
484
+
485
+ assert captured_api["api"] == session.connection.balancesheet_vip
486
+
487
+
488
+ # ============================================================================
489
+ # Integration Tests
490
+ # ============================================================================
491
+
492
+
493
+ def test_companydebt_full_workflow(sample_source_data):
494
+ """Test complete workflow from initialization to output"""
495
+ fake_conn = FakeConnection(frame=sample_source_data)
496
+ session = FakeSession(fake_conn)
497
+
498
+ debt = CompanyDebt(
499
+ session=session,
500
+ params={"ts_code": "000001.SZ", "start_date": "20200101", "end_date": "20201231"},
501
+ cache=True,
502
+ )
503
+
504
+ result = debt.run()
505
+
506
+ # Verify output structure
507
+ assert isinstance(result, pd.DataFrame)
508
+ assert len(result) == 3
509
+ assert "code" in result.columns
510
+ assert "date" in result.columns
511
+ assert "total_assets" in result.columns
512
+ assert "total_liab" in result.columns
513
+
514
+ # Verify data types
515
+ assert pd.api.types.is_numeric_dtype(result["total_assets"])
516
+ assert result.iloc[0]["code"] == "000001.SZ"
517
+
518
+
519
+ def test_companydebt_cache_persistence(sample_source_data):
520
+ """Test that cache persists across multiple runs"""
521
+ fake_conn = FakeConnection(frame=sample_source_data)
522
+ session = FakeSession(fake_conn)
523
+ debt = CompanyDebt(session=session, params={"ts_code": "000001.SZ"}, cache=True)
524
+
525
+ # Run once to populate cache
526
+ result1 = debt.run()
527
+
528
+ # Clear in-memory data to simulate fresh load
529
+ debt2 = CompanyDebt(session=session, params={"ts_code": "000001.SZ"}, cache=True)
530
+ result2 = debt2.run()
531
+
532
+ pd.testing.assert_frame_equal(result1, result2)
533
+
534
+
535
+ def test_companydebt_params_uniqueness(mock_session):
536
+ """Test that different params produce different cache keys"""
537
+ debt1 = CompanyDebt(
538
+ session=mock_session,
539
+ params={"ts_code": "000001.SZ", "start_date": "20200101"},
540
+ cache=True,
541
+ )
542
+ debt2 = CompanyDebt(
543
+ session=mock_session,
544
+ params={"ts_code": "000001.SZ", "start_date": "20210101"},
545
+ cache=True,
546
+ )
547
+
548
+ # Test that different params are properly stored
549
+ assert debt1.params.get("start_date") == "20200101"
550
+ assert debt2.params.get("start_date") == "20210101"
551
+ assert debt1.params.get("start_date") != debt2.params.get("start_date")
552
+
553
+
554
+ def test_companydebt_different_stocks(sample_source_data):
555
+ """Test that different stock codes are handled correctly"""
556
+ fake_conn = FakeConnection(frame=sample_source_data)
557
+ session = FakeSession(fake_conn)
558
+
559
+ debt1 = CompanyDebt(session=session, params={"ts_code": "000001.SZ"})
560
+ result1 = debt1.run()
561
+
562
+ debt2 = CompanyDebt(session=session, params={"ts_code": "000002.SZ"})
563
+ result2 = debt2.run()
564
+
565
+ # Both should have data for their respective stocks
566
+ assert "000001.SZ" in result1["code"].values
567
+ assert "000002.SZ" in result2["code"].values
568
+
569
+
570
+ def test_companydebt_empty_result_handling():
571
+ """Test handling of empty API results"""
572
+ empty_data = pd.DataFrame()
573
+ fake_conn = FakeConnection(frame=empty_data)
574
+ session = FakeSession(fake_conn)
575
+ debt = CompanyDebt(session=session, params={"ts_code": "000001.SZ"})
576
+
577
+ result = debt.run()
578
+
579
+ assert isinstance(result, pd.DataFrame)
580
+ assert result.empty
581
+ assert len(result.columns) > 0
582
+
583
+
584
+ def test_companydebt_large_dataset_handling():
585
+ """Test handling of large datasets"""
586
+ # Create large dataset
587
+ large_data = pd.DataFrame(
588
+ {
589
+ "ts_code": ["000001.SZ"] * 1000,
590
+ "ann_date": ["20200430"] * 1000,
591
+ "f_ann_date": ["20200430"] * 1000,
592
+ "end_date": ["20200331"] * 1000,
593
+ "report_type": ["1"] * 1000,
594
+ "comp_type": ["1"] * 1000,
595
+ "end_type": ["Q1"] * 1000,
596
+ "total_assets": ["1000000.00"] * 1000,
597
+ "update_flag": ["0"] * 1000,
598
+ }
599
+ )
600
+
601
+ fake_conn = FakeConnection(frame=large_data)
602
+ session = FakeSession(fake_conn)
603
+ debt = CompanyDebt(session=session, params={"ts_code": "000001.SZ"})
604
+
605
+ result = debt.run()
606
+
607
+ # Should deduplicate to 1 row
608
+ assert len(result) == 1
609
+
610
+
611
+ def test_companydebt_without_cache(sample_source_data):
612
+ """Test that class works correctly without caching"""
613
+ fake_conn = FakeConnection(frame=sample_source_data)
614
+ session = FakeSession(fake_conn)
615
+ debt = CompanyDebt(session=session, params={"ts_code": "000001.SZ"}, cache=False)
616
+
617
+ result = debt.run()
618
+
619
+ assert isinstance(result, pd.DataFrame)
620
+ assert len(result) > 0
621
+ assert debt.cache is None
622
+
623
+
624
+ def test_companydebt_handles_missing_numeric_fields():
625
+ """Test that missing numeric fields don't break transformation"""
626
+ # Data with only subset of fields
627
+ minimal_data = pd.DataFrame(
628
+ {
629
+ "ts_code": ["000001.SZ"],
630
+ "ann_date": ["20200430"],
631
+ "f_ann_date": ["20200430"],
632
+ "end_date": ["20200331"],
633
+ "report_type": ["1"],
634
+ "comp_type": ["1"],
635
+ "end_type": ["Q1"],
636
+ "total_assets": ["1000000.00"],
637
+ "update_flag": ["0"],
638
+ }
639
+ )
640
+
641
+ fake_conn = FakeConnection(frame=minimal_data)
642
+ session = FakeSession(fake_conn)
643
+ debt = CompanyDebt(session=session, params={"ts_code": "000001.SZ"})
644
+
645
+ result = debt.run()
646
+
647
+ # Should complete without error
648
+ assert len(result) == 1
649
+ # Missing fields should be NaN
650
+ assert pd.isna(result.iloc[0]["total_liab"])
651
+
652
+
653
+ def test_companydebt_api_doc_reference():
654
+ """Test that class correctly references API documentation"""
655
+ assert "doc_id=36" in CompanyDebt.__doc__
@@ -0,0 +1,21 @@
1
+ from __future__ import annotations
2
+
3
+ from xfintech.data.source.tushare.stock.companyoverview.companyoverview import (
4
+ CompanyOverview,
5
+ )
6
+ from xfintech.data.source.tushare.stock.companyoverview.constant import (
7
+ KEY,
8
+ NAME,
9
+ PAGINATE,
10
+ SOURCE,
11
+ TARGET,
12
+ )
13
+
14
+ __all__ = [
15
+ "CompanyOverview",
16
+ "KEY",
17
+ "NAME",
18
+ "PAGINATE",
19
+ "SOURCE",
20
+ "TARGET",
21
+ ]