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.
- lib_x17_fintech-2.1.3.dist-info/METADATA +633 -0
- lib_x17_fintech-2.1.3.dist-info/RECORD +282 -0
- lib_x17_fintech-2.1.3.dist-info/WHEEL +5 -0
- lib_x17_fintech-2.1.3.dist-info/licenses/LICENSE +1 -0
- lib_x17_fintech-2.1.3.dist-info/top_level.txt +1 -0
- xfintech/__init__.py +0 -0
- xfintech/connect/__init__.py +18 -0
- xfintech/connect/artifact/__init__.py +5 -0
- xfintech/connect/artifact/artifact.py +168 -0
- xfintech/connect/artifact/tests/__init__.py +3 -0
- xfintech/connect/artifact/tests/test_class_artifact_all.py +564 -0
- xfintech/connect/common/__init__.py +12 -0
- xfintech/connect/common/connect.py +49 -0
- xfintech/connect/common/connectref.py +119 -0
- xfintech/connect/common/error.py +62 -0
- xfintech/connect/common/tests/__init__.py +1 -0
- xfintech/connect/common/tests/test_class_connectlike_all.py +544 -0
- xfintech/connect/common/tests/test_class_connectref_all.py +586 -0
- xfintech/connect/common/tests/test_class_errors_all.py +524 -0
- xfintech/connect/instance/__init__.py +7 -0
- xfintech/connect/instance/macos.py +121 -0
- xfintech/connect/instance/s3.py +176 -0
- xfintech/connect/instance/tests/__init__.py +1 -0
- xfintech/connect/instance/tests/test_class_macosconnect_all.py +692 -0
- xfintech/connect/instance/tests/test_class_s3connect_all.py +603 -0
- xfintech/data/__init__.py +20 -0
- xfintech/data/common/__init__.py +15 -0
- xfintech/data/common/cache.py +186 -0
- xfintech/data/common/coolant.py +171 -0
- xfintech/data/common/metric.py +138 -0
- xfintech/data/common/paginate.py +132 -0
- xfintech/data/common/params.py +162 -0
- xfintech/data/common/retry.py +201 -0
- xfintech/data/common/tests/__init__.py +1 -0
- xfintech/data/common/tests/test_class_cache_all.py +681 -0
- xfintech/data/common/tests/test_class_coolant_all.py +534 -0
- xfintech/data/common/tests/test_class_metric_all.py +705 -0
- xfintech/data/common/tests/test_class_paginate_all.py +508 -0
- xfintech/data/common/tests/test_class_params_all.py +891 -0
- xfintech/data/common/tests/test_class_retry_all.py +714 -0
- xfintech/data/job/__init__.py +17 -0
- xfintech/data/job/errors.py +112 -0
- xfintech/data/job/house.py +156 -0
- xfintech/data/job/job.py +247 -0
- xfintech/data/job/joblike.py +47 -0
- xfintech/data/job/tests/__init__.py +1 -0
- xfintech/data/job/tests/test_class_errors_all.py +275 -0
- xfintech/data/job/tests/test_class_house_all.py +801 -0
- xfintech/data/job/tests/test_class_job_all.py +684 -0
- xfintech/data/job/tests/test_class_joblike_all.py +482 -0
- xfintech/data/relay/__init__.py +7 -0
- xfintech/data/relay/client.py +114 -0
- xfintech/data/relay/clientlike.py +45 -0
- xfintech/data/relay/tests/test_class_relayclient_all.py +484 -0
- xfintech/data/relay/tests/test_class_relayclientlike_all.py +500 -0
- xfintech/data/source/__init__.py +7 -0
- xfintech/data/source/baostock/__init__.py +21 -0
- xfintech/data/source/baostock/job/__init__.py +5 -0
- xfintech/data/source/baostock/job/job.py +217 -0
- xfintech/data/source/baostock/job/tests/__init__.py +0 -0
- xfintech/data/source/baostock/job/tests/test_class_baostockjob_all.py +547 -0
- xfintech/data/source/baostock/session/__init__.py +8 -0
- xfintech/data/source/baostock/session/relay.py +223 -0
- xfintech/data/source/baostock/session/session.py +241 -0
- xfintech/data/source/baostock/session/tests/__init__.py +0 -0
- xfintech/data/source/baostock/session/tests/test_class_relay_all.py +694 -0
- xfintech/data/source/baostock/session/tests/test_class_session_all.py +505 -0
- xfintech/data/source/baostock/stock/__init__.py +0 -0
- xfintech/data/source/baostock/stock/hs300stock/__init__.py +3 -0
- xfintech/data/source/baostock/stock/hs300stock/constant.py +49 -0
- xfintech/data/source/baostock/stock/hs300stock/hs300stock.py +133 -0
- xfintech/data/source/baostock/stock/hs300stock/tests/__init__.py +1 -0
- xfintech/data/source/baostock/stock/hs300stock/tests/test_class_hs300index_all.py +413 -0
- xfintech/data/source/baostock/stock/minuteline/__init__.py +19 -0
- xfintech/data/source/baostock/stock/minuteline/constant.py +89 -0
- xfintech/data/source/baostock/stock/minuteline/minuteline.py +163 -0
- xfintech/data/source/baostock/stock/minuteline/tests/__init__.py +0 -0
- xfintech/data/source/baostock/stock/minuteline/tests/test_class_minuteline_all.py +582 -0
- xfintech/data/source/baostock/stock/stock/__init__.py +19 -0
- xfintech/data/source/baostock/stock/stock/constant.py +55 -0
- xfintech/data/source/baostock/stock/stock/stock.py +149 -0
- xfintech/data/source/baostock/stock/stock/tests/__init__.py +0 -0
- xfintech/data/source/baostock/stock/stock/tests/test_class_stock_all.py +508 -0
- xfintech/data/source/baostock/stock/stockinfo/__init__.py +5 -0
- xfintech/data/source/baostock/stock/stockinfo/constant.py +66 -0
- xfintech/data/source/baostock/stock/stockinfo/stockinfo.py +176 -0
- xfintech/data/source/baostock/stock/stockinfo/tests/__init__.py +1 -0
- xfintech/data/source/baostock/stock/stockinfo/tests/test_class_stockinfo_all.py +617 -0
- xfintech/data/source/baostock/stock/sz50stock/__init__.py +3 -0
- xfintech/data/source/baostock/stock/sz50stock/constant.py +49 -0
- xfintech/data/source/baostock/stock/sz50stock/sz50stock.py +133 -0
- xfintech/data/source/baostock/stock/sz50stock/tests/__init__.py +1 -0
- xfintech/data/source/baostock/stock/sz50stock/tests/test_class_sz50stock_all.py +397 -0
- xfintech/data/source/baostock/stock/tradedate/__init__.py +19 -0
- xfintech/data/source/baostock/stock/tradedate/constant.py +72 -0
- xfintech/data/source/baostock/stock/tradedate/tests/__init__.py +0 -0
- xfintech/data/source/baostock/stock/tradedate/tests/test_class_tradedate_all.py +695 -0
- xfintech/data/source/baostock/stock/tradedate/tradedate.py +208 -0
- xfintech/data/source/baostock/stock/zz500stock/__init__.py +3 -0
- xfintech/data/source/baostock/stock/zz500stock/constant.py +55 -0
- xfintech/data/source/baostock/stock/zz500stock/tests/__init__.py +1 -0
- xfintech/data/source/baostock/stock/zz500stock/tests/test_class_zz500stock_all.py +421 -0
- xfintech/data/source/baostock/stock/zz500stock/zz500stock.py +133 -0
- xfintech/data/source/tushare/__init__.py +61 -0
- xfintech/data/source/tushare/job/__init__.py +5 -0
- xfintech/data/source/tushare/job/job.py +257 -0
- xfintech/data/source/tushare/job/tests/test_class_tusharejob_all.py +589 -0
- xfintech/data/source/tushare/session/__init__.py +5 -0
- xfintech/data/source/tushare/session/relay.py +231 -0
- xfintech/data/source/tushare/session/session.py +239 -0
- xfintech/data/source/tushare/session/tests/test_class_relay_all.py +719 -0
- xfintech/data/source/tushare/session/tests/test_class_session_all.py +705 -0
- xfintech/data/source/tushare/stock/__init__.py +55 -0
- xfintech/data/source/tushare/stock/adjfactor/__init__.py +19 -0
- xfintech/data/source/tushare/stock/adjfactor/adjfactor.py +150 -0
- xfintech/data/source/tushare/stock/adjfactor/constant.py +71 -0
- xfintech/data/source/tushare/stock/adjfactor/tests/__init__.py +0 -0
- xfintech/data/source/tushare/stock/adjfactor/tests/test_class_adjfactor_all.py +372 -0
- xfintech/data/source/tushare/stock/capflow/__init__.py +19 -0
- xfintech/data/source/tushare/stock/capflow/capflow.py +171 -0
- xfintech/data/source/tushare/stock/capflow/constant.py +105 -0
- xfintech/data/source/tushare/stock/capflow/tests/__init__.py +0 -0
- xfintech/data/source/tushare/stock/capflow/tests/test_class_capflow_all.py +589 -0
- xfintech/data/source/tushare/stock/capflowdc/__init__.py +19 -0
- xfintech/data/source/tushare/stock/capflowdc/capflowdc.py +167 -0
- xfintech/data/source/tushare/stock/capflowdc/constant.py +95 -0
- xfintech/data/source/tushare/stock/capflowdc/tests/__init__.py +0 -0
- xfintech/data/source/tushare/stock/capflowdc/tests/test_class_capflowdc_all.py +814 -0
- xfintech/data/source/tushare/stock/capflowths/__init__.py +19 -0
- xfintech/data/source/tushare/stock/capflowths/capflowths.py +173 -0
- xfintech/data/source/tushare/stock/capflowths/constant.py +92 -0
- xfintech/data/source/tushare/stock/capflowths/tests/__init__.py +0 -0
- xfintech/data/source/tushare/stock/capflowths/tests/test_class_capflowths_all.py +551 -0
- xfintech/data/source/tushare/stock/company/__init__.py +19 -0
- xfintech/data/source/tushare/stock/company/company.py +188 -0
- xfintech/data/source/tushare/stock/company/constant.py +92 -0
- xfintech/data/source/tushare/stock/company/tests/__init__.py +1 -0
- xfintech/data/source/tushare/stock/company/tests/test_class_company_all.py +829 -0
- xfintech/data/source/tushare/stock/companybusiness/__init__.py +21 -0
- xfintech/data/source/tushare/stock/companybusiness/companybusiness.py +183 -0
- xfintech/data/source/tushare/stock/companybusiness/constant.py +91 -0
- xfintech/data/source/tushare/stock/companybusiness/tests/__init__.py +0 -0
- xfintech/data/source/tushare/stock/companybusiness/tests/test_class_companybusiness_all.py +633 -0
- xfintech/data/source/tushare/stock/companycashflow/__init__.py +21 -0
- xfintech/data/source/tushare/stock/companycashflow/companycashflow.py +277 -0
- xfintech/data/source/tushare/stock/companycashflow/constant.py +293 -0
- xfintech/data/source/tushare/stock/companycashflow/tests/__init__.py +0 -0
- xfintech/data/source/tushare/stock/companycashflow/tests/test_class_companycashflow_all.py +619 -0
- xfintech/data/source/tushare/stock/companydebt/__init__.py +19 -0
- xfintech/data/source/tushare/stock/companydebt/companydebt.py +339 -0
- xfintech/data/source/tushare/stock/companydebt/constant.py +403 -0
- xfintech/data/source/tushare/stock/companydebt/tests/__init__.py +0 -0
- xfintech/data/source/tushare/stock/companydebt/tests/test_class_companydebt_all.py +655 -0
- xfintech/data/source/tushare/stock/companyoverview/__init__.py +21 -0
- xfintech/data/source/tushare/stock/companyoverview/companyoverview.py +214 -0
- xfintech/data/source/tushare/stock/companyoverview/constant.py +152 -0
- xfintech/data/source/tushare/stock/companyoverview/tests/__init__.py +0 -0
- xfintech/data/source/tushare/stock/companyoverview/tests/test_class_companyoverview_all.py +647 -0
- xfintech/data/source/tushare/stock/companyprofit/__init__.py +21 -0
- xfintech/data/source/tushare/stock/companyprofit/companyprofit.py +272 -0
- xfintech/data/source/tushare/stock/companyprofit/constant.py +259 -0
- xfintech/data/source/tushare/stock/companyprofit/tests/__init__.py +0 -0
- xfintech/data/source/tushare/stock/companyprofit/tests/test_class_companyprofit_all.py +635 -0
- xfintech/data/source/tushare/stock/conceptcapflowdc/__init__.py +21 -0
- xfintech/data/source/tushare/stock/conceptcapflowdc/conceptcapflowdc.py +175 -0
- xfintech/data/source/tushare/stock/conceptcapflowdc/constant.py +106 -0
- xfintech/data/source/tushare/stock/conceptcapflowdc/tests/__init__.py +0 -0
- xfintech/data/source/tushare/stock/conceptcapflowdc/tests/test_class_conceptcapflowdc_all.py +568 -0
- xfintech/data/source/tushare/stock/conceptcapflowths/__init__.py +21 -0
- xfintech/data/source/tushare/stock/conceptcapflowths/conceptcapflowths.py +188 -0
- xfintech/data/source/tushare/stock/conceptcapflowths/constant.py +89 -0
- xfintech/data/source/tushare/stock/conceptcapflowths/tests/__init__.py +0 -0
- xfintech/data/source/tushare/stock/conceptcapflowths/tests/test_class_conceptcapflowths_all.py +516 -0
- xfintech/data/source/tushare/stock/dayline/__init__.py +19 -0
- xfintech/data/source/tushare/stock/dayline/constant.py +87 -0
- xfintech/data/source/tushare/stock/dayline/dayline.py +177 -0
- xfintech/data/source/tushare/stock/dayline/tests/__init__.py +0 -0
- xfintech/data/source/tushare/stock/dayline/tests/test_class_dayline_all.py +585 -0
- xfintech/data/source/tushare/stock/industrycapflowths/__init__.py +21 -0
- xfintech/data/source/tushare/stock/industrycapflowths/constant.py +89 -0
- xfintech/data/source/tushare/stock/industrycapflowths/industrycapflowths.py +192 -0
- xfintech/data/source/tushare/stock/industrycapflowths/tests/__init__.py +0 -0
- xfintech/data/source/tushare/stock/industrycapflowths/tests/test_class_industrycapflowths_all.py +683 -0
- xfintech/data/source/tushare/stock/marketindexcapflowdc/__init__.py +21 -0
- xfintech/data/source/tushare/stock/marketindexcapflowdc/constant.py +90 -0
- xfintech/data/source/tushare/stock/marketindexcapflowdc/marketindexcapflowdc.py +173 -0
- xfintech/data/source/tushare/stock/marketindexcapflowdc/tests/__init__.py +0 -0
- xfintech/data/source/tushare/stock/marketindexcapflowdc/tests/test_class_marketindexcapflowdc_all.py +793 -0
- xfintech/data/source/tushare/stock/monthline/__init__.py +19 -0
- xfintech/data/source/tushare/stock/monthline/constant.py +87 -0
- xfintech/data/source/tushare/stock/monthline/monthline.py +180 -0
- xfintech/data/source/tushare/stock/monthline/tests/__init__.py +0 -0
- xfintech/data/source/tushare/stock/monthline/tests/test_class_monthline_all.py +574 -0
- xfintech/data/source/tushare/stock/stock/__init__.py +19 -0
- xfintech/data/source/tushare/stock/stock/constant.py +105 -0
- xfintech/data/source/tushare/stock/stock/stock.py +193 -0
- xfintech/data/source/tushare/stock/stock/tests/__init__.py +0 -0
- xfintech/data/source/tushare/stock/stock/tests/test_class_stock_all.py +788 -0
- xfintech/data/source/tushare/stock/stockdividend/__init__.py +21 -0
- xfintech/data/source/tushare/stock/stockdividend/constant.py +111 -0
- xfintech/data/source/tushare/stock/stockdividend/stockdividend.py +180 -0
- xfintech/data/source/tushare/stock/stockdividend/tests/__init__.py +0 -0
- xfintech/data/source/tushare/stock/stockdividend/tests/test_class_stockdividend_all.py +725 -0
- xfintech/data/source/tushare/stock/stockinfo/__init__.py +19 -0
- xfintech/data/source/tushare/stock/stockinfo/constant.py +104 -0
- xfintech/data/source/tushare/stock/stockinfo/stockinfo.py +208 -0
- xfintech/data/source/tushare/stock/stockinfo/tests/__init__.py +0 -0
- xfintech/data/source/tushare/stock/stockinfo/tests/test_class_stockinfo_all.py +881 -0
- xfintech/data/source/tushare/stock/stockipo/__init__.py +19 -0
- xfintech/data/source/tushare/stock/stockipo/constant.py +90 -0
- xfintech/data/source/tushare/stock/stockipo/stockipo.py +234 -0
- xfintech/data/source/tushare/stock/stockipo/tests/__init__.py +1 -0
- xfintech/data/source/tushare/stock/stockipo/tests/test_class_stockipo_all.py +750 -0
- xfintech/data/source/tushare/stock/stockpledge/__init__.py +19 -0
- xfintech/data/source/tushare/stock/stockpledge/constant.py +72 -0
- xfintech/data/source/tushare/stock/stockpledge/stockpledge.py +158 -0
- xfintech/data/source/tushare/stock/stockpledge/tests/__init__.py +0 -0
- xfintech/data/source/tushare/stock/stockpledge/tests/test_class_stockpledge_all.py +664 -0
- xfintech/data/source/tushare/stock/stockpledgedetail/__init__.py +21 -0
- xfintech/data/source/tushare/stock/stockpledgedetail/constant.py +85 -0
- xfintech/data/source/tushare/stock/stockpledgedetail/stockpledgedetail.py +171 -0
- xfintech/data/source/tushare/stock/stockpledgedetail/tests/__init__.py +0 -0
- xfintech/data/source/tushare/stock/stockpledgedetail/tests/test_class_stockpledgedetail_all.py +112 -0
- xfintech/data/source/tushare/stock/stockst/__init__.py +19 -0
- xfintech/data/source/tushare/stock/stockst/constant.py +80 -0
- xfintech/data/source/tushare/stock/stockst/stockst.py +189 -0
- xfintech/data/source/tushare/stock/stockst/tests/__init__.py +0 -0
- xfintech/data/source/tushare/stock/stockst/tests/test_class_stockst_all.py +693 -0
- xfintech/data/source/tushare/stock/stocksuspend/__init__.py +21 -0
- xfintech/data/source/tushare/stock/stocksuspend/constant.py +75 -0
- xfintech/data/source/tushare/stock/stocksuspend/stocksuspend.py +151 -0
- xfintech/data/source/tushare/stock/stocksuspend/tests/__init__.py +0 -0
- xfintech/data/source/tushare/stock/stocksuspend/tests/test_class_stocksuspend_all.py +626 -0
- xfintech/data/source/tushare/stock/techindex/__init__.py +19 -0
- xfintech/data/source/tushare/stock/techindex/constant.py +600 -0
- xfintech/data/source/tushare/stock/techindex/techindex.py +314 -0
- xfintech/data/source/tushare/stock/techindex/tests/__init__.py +0 -0
- xfintech/data/source/tushare/stock/techindex/tests/test_class_techindex_all.py +576 -0
- xfintech/data/source/tushare/stock/tradedate/__init__.py +19 -0
- xfintech/data/source/tushare/stock/tradedate/constant.py +93 -0
- xfintech/data/source/tushare/stock/tradedate/tests/__init__.py +0 -0
- xfintech/data/source/tushare/stock/tradedate/tests/test_class_tradedate_all.py +947 -0
- xfintech/data/source/tushare/stock/tradedate/tradedate.py +234 -0
- xfintech/data/source/tushare/stock/weekline/__init__.py +19 -0
- xfintech/data/source/tushare/stock/weekline/constant.py +87 -0
- xfintech/data/source/tushare/stock/weekline/tests/__init__.py +0 -0
- xfintech/data/source/tushare/stock/weekline/tests/test_class_weekline_all.py +575 -0
- xfintech/data/source/tushare/stock/weekline/weekline.py +182 -0
- xfintech/fabric/__init__.py +18 -0
- xfintech/fabric/column/__init__.py +7 -0
- xfintech/fabric/column/info.py +202 -0
- xfintech/fabric/column/kind.py +102 -0
- xfintech/fabric/column/tests/__init__.py +0 -0
- xfintech/fabric/column/tests/test_class_info_all.py +207 -0
- xfintech/fabric/column/tests/test_class_kind_all.py +80 -0
- xfintech/fabric/table/__init__.py +5 -0
- xfintech/fabric/table/info.py +263 -0
- xfintech/fabric/table/tests/__init__.py +0 -0
- xfintech/fabric/table/tests/test_class_info_all.py +547 -0
- xfintech/serde/__init__.py +35 -0
- xfintech/serde/common/__init__.py +9 -0
- xfintech/serde/common/dataformat.py +78 -0
- xfintech/serde/common/deserialiserlike.py +38 -0
- xfintech/serde/common/error.py +182 -0
- xfintech/serde/common/serialiserlike.py +38 -0
- xfintech/serde/common/tests/__init__.py +1 -0
- xfintech/serde/common/tests/test_class_dataformat_all.py +694 -0
- xfintech/serde/common/tests/test_class_deserialiserlike_all.py +500 -0
- xfintech/serde/common/tests/test_class_errors_all.py +518 -0
- xfintech/serde/common/tests/test_class_serialiserlike_all.py +401 -0
- xfintech/serde/deserialiser/__init__.py +7 -0
- xfintech/serde/deserialiser/pandas.py +113 -0
- xfintech/serde/deserialiser/python.py +68 -0
- xfintech/serde/deserialiser/tests/__init__.py +1 -0
- xfintech/serde/deserialiser/tests/test_class_pandasdeserialiser_all.py +503 -0
- xfintech/serde/deserialiser/tests/test_class_pythondeserialiser_all.py +570 -0
- xfintech/serde/serialiser/__init__.py +7 -0
- xfintech/serde/serialiser/pandas.py +116 -0
- xfintech/serde/serialiser/python.py +71 -0
- xfintech/serde/serialiser/tests/__init__.py +1 -0
- xfintech/serde/serialiser/tests/test_class_pandasserialiser_all.py +474 -0
- xfintech/serde/serialiser/tests/test_class_pythonserialiser_all.py +508 -0
|
@@ -0,0 +1,508 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Test suite for Paginate class
|
|
3
|
+
Tests cover initialization, pagination operations, offset management, and data conversion
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
from xfintech.data.common.paginate import Paginate
|
|
7
|
+
|
|
8
|
+
# ============================================================================
|
|
9
|
+
# Initialization Tests
|
|
10
|
+
# ============================================================================
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def test_paginate_init_defaults():
|
|
14
|
+
"""Test Paginate initialization with default values"""
|
|
15
|
+
paginator = Paginate()
|
|
16
|
+
assert paginator.pagesize == 5000
|
|
17
|
+
assert paginator.pagelimit == 10000
|
|
18
|
+
assert paginator.offset == 0
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def test_paginate_init_custom_values():
|
|
22
|
+
"""Test Paginate initialization with custom values"""
|
|
23
|
+
paginator = Paginate(pagelimit=20000, pagesize=1000, offset=500)
|
|
24
|
+
assert paginator.pagesize == 1000
|
|
25
|
+
assert paginator.pagelimit == 20000
|
|
26
|
+
assert paginator.offset == 500
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def test_paginate_init_partial_custom():
|
|
30
|
+
"""Test Paginate initialization with partial custom values"""
|
|
31
|
+
paginator = Paginate(pagesize=2000)
|
|
32
|
+
assert paginator.pagesize == 2000
|
|
33
|
+
assert paginator.pagelimit == 10000
|
|
34
|
+
assert paginator.offset == 0
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def test_paginate_init_zero_values():
|
|
38
|
+
"""Test Paginate initialization with zero values falls back to defaults"""
|
|
39
|
+
paginator = Paginate(pagelimit=0, pagesize=0, offset=0)
|
|
40
|
+
assert paginator.pagesize == 5000
|
|
41
|
+
assert paginator.pagelimit == 10000
|
|
42
|
+
assert paginator.offset == 0
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def test_paginate_init_negative_pagelimit():
|
|
46
|
+
"""Test Paginate initialization with negative pagelimit falls back to default"""
|
|
47
|
+
paginator = Paginate(pagelimit=-100)
|
|
48
|
+
assert paginator.pagelimit == 10000
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
def test_paginate_init_negative_pagesize():
|
|
52
|
+
"""Test Paginate initialization with negative pagesize falls back to default"""
|
|
53
|
+
paginator = Paginate(pagesize=-50)
|
|
54
|
+
assert paginator.pagesize == 5000
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
def test_paginate_init_negative_offset():
|
|
58
|
+
"""Test Paginate initialization with negative offset falls back to default"""
|
|
59
|
+
paginator = Paginate(offset=-10)
|
|
60
|
+
assert paginator.offset == 0
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
def test_paginate_constants():
|
|
64
|
+
"""Test Paginate class constants"""
|
|
65
|
+
assert Paginate.DEFAULT_PAGESIZE == 5000
|
|
66
|
+
assert Paginate.DEFAULT_PAGELIMIT == 10000
|
|
67
|
+
assert Paginate.DEFAULT_OFFSET == 0
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
# ============================================================================
|
|
71
|
+
# Resolve Methods Tests
|
|
72
|
+
# ============================================================================
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
def test_paginate_resolve_pagelimit_valid():
|
|
76
|
+
"""Test _resolve_pagelimit with valid value"""
|
|
77
|
+
paginator = Paginate()
|
|
78
|
+
assert paginator._resolve_pagelimit(15000) == 15000
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
def test_paginate_resolve_pagelimit_invalid():
|
|
82
|
+
"""Test _resolve_pagelimit with invalid value"""
|
|
83
|
+
paginator = Paginate()
|
|
84
|
+
assert paginator._resolve_pagelimit(0) == 10000
|
|
85
|
+
assert paginator._resolve_pagelimit(-100) == 10000
|
|
86
|
+
assert paginator._resolve_pagelimit(None) == 10000
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
def test_paginate_resolve_pagesize_valid():
|
|
90
|
+
"""Test _resolve_pagesize with valid value"""
|
|
91
|
+
paginator = Paginate()
|
|
92
|
+
assert paginator._resolve_pagesize(1000) == 1000
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
def test_paginate_resolve_pagesize_invalid():
|
|
96
|
+
"""Test _resolve_pagesize with invalid value"""
|
|
97
|
+
paginator = Paginate()
|
|
98
|
+
assert paginator._resolve_pagesize(0) == 5000
|
|
99
|
+
assert paginator._resolve_pagesize(-50) == 5000
|
|
100
|
+
assert paginator._resolve_pagesize(None) == 5000
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
def test_paginate_resolve_offset_valid():
|
|
104
|
+
"""Test _resolve_offset with valid value"""
|
|
105
|
+
paginator = Paginate()
|
|
106
|
+
assert paginator._resolve_offset(100) == 100
|
|
107
|
+
assert paginator._resolve_offset(0) == 0
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
def test_paginate_resolve_offset_invalid():
|
|
111
|
+
"""Test _resolve_offset with invalid value"""
|
|
112
|
+
paginator = Paginate()
|
|
113
|
+
assert paginator._resolve_offset(-10) == 0
|
|
114
|
+
assert paginator._resolve_offset(None) == 0
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
# ============================================================================
|
|
118
|
+
# Reset Method Tests
|
|
119
|
+
# ============================================================================
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
def test_paginate_reset_from_zero():
|
|
123
|
+
"""Test reset when offset is already zero"""
|
|
124
|
+
paginator = Paginate()
|
|
125
|
+
paginator.reset()
|
|
126
|
+
assert paginator.offset == 0
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
def test_paginate_reset_from_nonzero():
|
|
130
|
+
"""Test reset when offset is non-zero"""
|
|
131
|
+
paginator = Paginate(offset=5000)
|
|
132
|
+
assert paginator.offset == 5000
|
|
133
|
+
paginator.reset()
|
|
134
|
+
assert paginator.offset == 0
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
def test_paginate_reset_after_next():
|
|
138
|
+
"""Test reset after calling next"""
|
|
139
|
+
paginator = Paginate()
|
|
140
|
+
paginator.next()
|
|
141
|
+
paginator.next()
|
|
142
|
+
assert paginator.offset == 10000
|
|
143
|
+
paginator.reset()
|
|
144
|
+
assert paginator.offset == 0
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
def test_paginate_reset_preserves_other_attributes():
|
|
148
|
+
"""Test reset only affects offset, not other attributes"""
|
|
149
|
+
paginator = Paginate(pagelimit=20000, pagesize=1000, offset=5000)
|
|
150
|
+
paginator.reset()
|
|
151
|
+
assert paginator.offset == 0
|
|
152
|
+
assert paginator.pagesize == 1000
|
|
153
|
+
assert paginator.pagelimit == 20000
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
# ============================================================================
|
|
157
|
+
# Next Method Tests
|
|
158
|
+
# ============================================================================
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
def test_paginate_next_first_call():
|
|
162
|
+
"""Test first call to next advances offset by pagesize"""
|
|
163
|
+
paginator = Paginate(pagesize=1000, offset=0)
|
|
164
|
+
new_offset = paginator.next()
|
|
165
|
+
assert new_offset == 1000
|
|
166
|
+
assert paginator.offset == 1000
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
def test_paginate_next_multiple_calls():
|
|
170
|
+
"""Test multiple calls to next"""
|
|
171
|
+
paginator = Paginate(pagesize=500)
|
|
172
|
+
paginator.next()
|
|
173
|
+
assert paginator.offset == 500
|
|
174
|
+
paginator.next()
|
|
175
|
+
assert paginator.offset == 1000
|
|
176
|
+
paginator.next()
|
|
177
|
+
assert paginator.offset == 1500
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
def test_paginate_next_with_custom_pagesize():
|
|
181
|
+
"""Test next with custom pagesize"""
|
|
182
|
+
paginator = Paginate(pagesize=2500)
|
|
183
|
+
paginator.next()
|
|
184
|
+
assert paginator.offset == 2500
|
|
185
|
+
paginator.next()
|
|
186
|
+
assert paginator.offset == 5000
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
def test_paginate_next_with_existing_offset():
|
|
190
|
+
"""Test next with existing offset"""
|
|
191
|
+
paginator = Paginate(pagesize=1000, offset=3000)
|
|
192
|
+
paginator.next()
|
|
193
|
+
assert paginator.offset == 4000
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
def test_paginate_next_returns_new_offset():
|
|
197
|
+
"""Test next returns the new offset value"""
|
|
198
|
+
paginator = Paginate(pagesize=750)
|
|
199
|
+
result = paginator.next()
|
|
200
|
+
assert result == 750
|
|
201
|
+
result = paginator.next()
|
|
202
|
+
assert result == 1500
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
def test_paginate_next_large_pagesize():
|
|
206
|
+
"""Test next with large pagesize"""
|
|
207
|
+
paginator = Paginate(pagesize=100000)
|
|
208
|
+
paginator.next()
|
|
209
|
+
assert paginator.offset == 100000
|
|
210
|
+
|
|
211
|
+
|
|
212
|
+
# ============================================================================
|
|
213
|
+
# From Dict Tests
|
|
214
|
+
# ============================================================================
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
def test_paginate_from_dict_full():
|
|
218
|
+
"""Test from_dict with all fields"""
|
|
219
|
+
data = {"pagelimit": 15000, "pagesize": 2000, "offset": 1000}
|
|
220
|
+
paginator = Paginate.from_dict(data)
|
|
221
|
+
assert paginator.pagelimit == 15000
|
|
222
|
+
assert paginator.pagesize == 2000
|
|
223
|
+
assert paginator.offset == 1000
|
|
224
|
+
|
|
225
|
+
|
|
226
|
+
def test_paginate_from_dict_partial():
|
|
227
|
+
"""Test from_dict with partial fields"""
|
|
228
|
+
data = {"pagesize": 3000}
|
|
229
|
+
paginator = Paginate.from_dict(data)
|
|
230
|
+
assert paginator.pagesize == 3000
|
|
231
|
+
assert paginator.pagelimit == 10000
|
|
232
|
+
assert paginator.offset == 0
|
|
233
|
+
|
|
234
|
+
|
|
235
|
+
def test_paginate_from_dict_empty():
|
|
236
|
+
"""Test from_dict with empty dict"""
|
|
237
|
+
paginator = Paginate.from_dict({})
|
|
238
|
+
assert paginator.pagesize == 5000
|
|
239
|
+
assert paginator.pagelimit == 10000
|
|
240
|
+
assert paginator.offset == 0
|
|
241
|
+
|
|
242
|
+
|
|
243
|
+
def test_paginate_from_dict_with_paginate_instance():
|
|
244
|
+
"""Test from_dict with Paginate instance returns same instance"""
|
|
245
|
+
original = Paginate(pagelimit=20000, pagesize=1500, offset=500)
|
|
246
|
+
result = Paginate.from_dict(original)
|
|
247
|
+
assert result is original
|
|
248
|
+
assert result.pagelimit == 20000
|
|
249
|
+
assert result.pagesize == 1500
|
|
250
|
+
assert result.offset == 500
|
|
251
|
+
|
|
252
|
+
|
|
253
|
+
def test_paginate_from_dict_with_extra_fields():
|
|
254
|
+
"""Test from_dict ignores extra fields"""
|
|
255
|
+
data = {"pagelimit": 8000, "pagesize": 1000, "offset": 2000, "extra_field": "ignored", "another_field": 999}
|
|
256
|
+
paginator = Paginate.from_dict(data)
|
|
257
|
+
assert paginator.pagelimit == 8000
|
|
258
|
+
assert paginator.pagesize == 1000
|
|
259
|
+
assert paginator.offset == 2000
|
|
260
|
+
|
|
261
|
+
|
|
262
|
+
# ============================================================================
|
|
263
|
+
# Describe Method Tests
|
|
264
|
+
# ============================================================================
|
|
265
|
+
|
|
266
|
+
|
|
267
|
+
def test_paginate_describe_with_defaults():
|
|
268
|
+
"""Test describe with default values returns only non-zero/non-default values"""
|
|
269
|
+
paginator = Paginate()
|
|
270
|
+
result = paginator.describe()
|
|
271
|
+
assert "pagesize" in result
|
|
272
|
+
assert "pagelimit" in result
|
|
273
|
+
assert "offset" not in result # offset is 0, not included
|
|
274
|
+
|
|
275
|
+
|
|
276
|
+
def test_paginate_describe_with_custom_values():
|
|
277
|
+
"""Test describe with custom values"""
|
|
278
|
+
paginator = Paginate(pagelimit=15000, pagesize=2000, offset=4000)
|
|
279
|
+
result = paginator.describe()
|
|
280
|
+
assert result["pagesize"] == 2000
|
|
281
|
+
assert result["pagelimit"] == 15000
|
|
282
|
+
assert result["offset"] == 4000
|
|
283
|
+
|
|
284
|
+
|
|
285
|
+
def test_paginate_describe_with_zero_offset():
|
|
286
|
+
"""Test describe excludes zero offset"""
|
|
287
|
+
paginator = Paginate(pagelimit=20000, pagesize=1000, offset=0)
|
|
288
|
+
result = paginator.describe()
|
|
289
|
+
assert "pagesize" in result
|
|
290
|
+
assert "pagelimit" in result
|
|
291
|
+
assert "offset" not in result
|
|
292
|
+
|
|
293
|
+
|
|
294
|
+
def test_paginate_describe_after_next():
|
|
295
|
+
"""Test describe after calling next includes offset"""
|
|
296
|
+
paginator = Paginate(pagesize=1000)
|
|
297
|
+
paginator.next()
|
|
298
|
+
result = paginator.describe()
|
|
299
|
+
assert result["offset"] == 1000
|
|
300
|
+
|
|
301
|
+
|
|
302
|
+
def test_paginate_describe_after_reset():
|
|
303
|
+
"""Test describe after reset excludes offset"""
|
|
304
|
+
paginator = Paginate(offset=5000)
|
|
305
|
+
paginator.reset()
|
|
306
|
+
result = paginator.describe()
|
|
307
|
+
assert "offset" not in result
|
|
308
|
+
|
|
309
|
+
|
|
310
|
+
# ============================================================================
|
|
311
|
+
# To Dict Method Tests
|
|
312
|
+
# ============================================================================
|
|
313
|
+
|
|
314
|
+
|
|
315
|
+
def test_paginate_to_dict_with_defaults():
|
|
316
|
+
"""Test to_dict with default values"""
|
|
317
|
+
paginator = Paginate()
|
|
318
|
+
result = paginator.to_dict()
|
|
319
|
+
assert result == {"pagesize": 5000, "pagelimit": 10000, "offset": 0}
|
|
320
|
+
|
|
321
|
+
|
|
322
|
+
def test_paginate_to_dict_with_custom_values():
|
|
323
|
+
"""Test to_dict with custom values"""
|
|
324
|
+
paginator = Paginate(pagelimit=20000, pagesize=1500, offset=3000)
|
|
325
|
+
result = paginator.to_dict()
|
|
326
|
+
assert result == {"pagesize": 1500, "pagelimit": 20000, "offset": 3000}
|
|
327
|
+
|
|
328
|
+
|
|
329
|
+
def test_paginate_to_dict_includes_all_fields():
|
|
330
|
+
"""Test to_dict always includes all fields"""
|
|
331
|
+
paginator = Paginate(offset=0)
|
|
332
|
+
result = paginator.to_dict()
|
|
333
|
+
assert "pagesize" in result
|
|
334
|
+
assert "pagelimit" in result
|
|
335
|
+
assert "offset" in result
|
|
336
|
+
assert result["offset"] == 0
|
|
337
|
+
|
|
338
|
+
|
|
339
|
+
def test_paginate_to_dict_structure():
|
|
340
|
+
"""Test to_dict returns expected structure"""
|
|
341
|
+
paginator = Paginate()
|
|
342
|
+
result = paginator.to_dict()
|
|
343
|
+
assert isinstance(result, dict)
|
|
344
|
+
assert len(result) == 3
|
|
345
|
+
assert all(key in result for key in ["pagesize", "pagelimit", "offset"])
|
|
346
|
+
|
|
347
|
+
|
|
348
|
+
def test_paginate_to_dict_vs_describe():
|
|
349
|
+
"""Test to_dict vs describe differences"""
|
|
350
|
+
paginator = Paginate(pagelimit=15000, pagesize=2000, offset=0)
|
|
351
|
+
to_dict_result = paginator.to_dict()
|
|
352
|
+
describe_result = paginator.describe()
|
|
353
|
+
|
|
354
|
+
# to_dict includes offset even when 0
|
|
355
|
+
assert "offset" in to_dict_result
|
|
356
|
+
assert to_dict_result["offset"] == 0
|
|
357
|
+
|
|
358
|
+
# describe excludes offset when 0
|
|
359
|
+
assert "offset" not in describe_result
|
|
360
|
+
|
|
361
|
+
|
|
362
|
+
# ============================================================================
|
|
363
|
+
# Integration Tests
|
|
364
|
+
# ============================================================================
|
|
365
|
+
|
|
366
|
+
|
|
367
|
+
def test_paginate_full_workflow():
|
|
368
|
+
"""Test complete pagination workflow"""
|
|
369
|
+
paginator = Paginate(pagelimit=10000, pagesize=1000, offset=0)
|
|
370
|
+
|
|
371
|
+
# Start at page 0
|
|
372
|
+
assert paginator.offset == 0
|
|
373
|
+
|
|
374
|
+
# Get page 1
|
|
375
|
+
paginator.next()
|
|
376
|
+
assert paginator.offset == 1000
|
|
377
|
+
|
|
378
|
+
# Get page 2
|
|
379
|
+
paginator.next()
|
|
380
|
+
assert paginator.offset == 2000
|
|
381
|
+
|
|
382
|
+
# Reset to start
|
|
383
|
+
paginator.reset()
|
|
384
|
+
assert paginator.offset == 0
|
|
385
|
+
|
|
386
|
+
|
|
387
|
+
def test_paginate_dict_roundtrip():
|
|
388
|
+
"""Test converting to dict and back"""
|
|
389
|
+
original = Paginate(pagelimit=15000, pagesize=2000, offset=1000)
|
|
390
|
+
data = original.to_dict()
|
|
391
|
+
restored = Paginate.from_dict(data)
|
|
392
|
+
|
|
393
|
+
assert restored.pagelimit == original.pagelimit
|
|
394
|
+
assert restored.pagesize == original.pagesize
|
|
395
|
+
assert restored.offset == original.offset
|
|
396
|
+
|
|
397
|
+
|
|
398
|
+
def test_paginate_sequential_pages():
|
|
399
|
+
"""Test sequential page navigation"""
|
|
400
|
+
paginator = Paginate(pagesize=100)
|
|
401
|
+
offsets = []
|
|
402
|
+
|
|
403
|
+
for i in range(5):
|
|
404
|
+
offsets.append(paginator.offset)
|
|
405
|
+
paginator.next()
|
|
406
|
+
|
|
407
|
+
assert offsets == [0, 100, 200, 300, 400]
|
|
408
|
+
assert paginator.offset == 500
|
|
409
|
+
|
|
410
|
+
|
|
411
|
+
def test_paginate_large_dataset():
|
|
412
|
+
"""Test pagination with large dataset"""
|
|
413
|
+
paginator = Paginate(pagelimit=1000000, pagesize=10000)
|
|
414
|
+
|
|
415
|
+
# Simulate fetching 10 pages
|
|
416
|
+
for _ in range(10):
|
|
417
|
+
paginator.next()
|
|
418
|
+
|
|
419
|
+
assert paginator.offset == 100000
|
|
420
|
+
|
|
421
|
+
|
|
422
|
+
def test_paginate_boundary_conditions():
|
|
423
|
+
"""Test pagination at boundary conditions"""
|
|
424
|
+
paginator = Paginate(pagelimit=10000, pagesize=2500)
|
|
425
|
+
|
|
426
|
+
# Fetch exactly 4 pages to reach limit
|
|
427
|
+
for _ in range(4):
|
|
428
|
+
paginator.next()
|
|
429
|
+
|
|
430
|
+
assert paginator.offset == 10000 # Reached the limit
|
|
431
|
+
|
|
432
|
+
|
|
433
|
+
def test_paginate_describe_dynamic():
|
|
434
|
+
"""Test describe changes as pagination progresses"""
|
|
435
|
+
paginator = Paginate(pagesize=1000)
|
|
436
|
+
|
|
437
|
+
# Initially, offset not in describe
|
|
438
|
+
desc1 = paginator.describe()
|
|
439
|
+
assert "offset" not in desc1
|
|
440
|
+
|
|
441
|
+
# After next, offset appears
|
|
442
|
+
paginator.next()
|
|
443
|
+
desc2 = paginator.describe()
|
|
444
|
+
assert "offset" in desc2
|
|
445
|
+
assert desc2["offset"] == 1000
|
|
446
|
+
|
|
447
|
+
# After reset, offset disappears again
|
|
448
|
+
paginator.reset()
|
|
449
|
+
desc3 = paginator.describe()
|
|
450
|
+
assert "offset" not in desc3
|
|
451
|
+
|
|
452
|
+
|
|
453
|
+
def test_paginate_multiple_instances():
|
|
454
|
+
"""Test multiple independent Paginate instances"""
|
|
455
|
+
p1 = Paginate(pagesize=1000)
|
|
456
|
+
p2 = Paginate(pagesize=2000)
|
|
457
|
+
|
|
458
|
+
p1.next()
|
|
459
|
+
p2.next()
|
|
460
|
+
|
|
461
|
+
assert p1.offset == 1000
|
|
462
|
+
assert p2.offset == 2000
|
|
463
|
+
|
|
464
|
+
|
|
465
|
+
def test_paginate_state_independence():
|
|
466
|
+
"""Test that paginate instances maintain independent state"""
|
|
467
|
+
p1 = Paginate(pagesize=500)
|
|
468
|
+
p2 = Paginate(pagesize=500)
|
|
469
|
+
|
|
470
|
+
p1.next()
|
|
471
|
+
p1.next()
|
|
472
|
+
|
|
473
|
+
assert p1.offset == 1000
|
|
474
|
+
assert p2.offset == 0
|
|
475
|
+
|
|
476
|
+
|
|
477
|
+
def test_paginate_custom_pagination_strategy():
|
|
478
|
+
"""Test custom pagination with specific requirements"""
|
|
479
|
+
# Small pages for API rate limiting
|
|
480
|
+
paginator = Paginate(pagelimit=50000, pagesize=100)
|
|
481
|
+
|
|
482
|
+
pages_fetched = 0
|
|
483
|
+
while paginator.offset < paginator.pagelimit:
|
|
484
|
+
paginator.next()
|
|
485
|
+
pages_fetched += 1
|
|
486
|
+
if pages_fetched >= 10: # Stop after 10 pages
|
|
487
|
+
break
|
|
488
|
+
|
|
489
|
+
assert paginator.offset == 1000
|
|
490
|
+
assert pages_fetched == 10
|
|
491
|
+
|
|
492
|
+
|
|
493
|
+
def test_paginate_modification_after_init():
|
|
494
|
+
"""Test direct modification of attributes after initialization"""
|
|
495
|
+
paginator = Paginate()
|
|
496
|
+
|
|
497
|
+
# Modify attributes directly
|
|
498
|
+
paginator.pagesize = 3000
|
|
499
|
+
paginator.pagelimit = 30000
|
|
500
|
+
paginator.offset = 6000
|
|
501
|
+
|
|
502
|
+
assert paginator.pagesize == 3000
|
|
503
|
+
assert paginator.pagelimit == 30000
|
|
504
|
+
assert paginator.offset == 6000
|
|
505
|
+
|
|
506
|
+
# Next should use modified pagesize
|
|
507
|
+
paginator.next()
|
|
508
|
+
assert paginator.offset == 9000
|