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,694 @@
|
|
|
1
|
+
import pytest
|
|
2
|
+
|
|
3
|
+
from xfintech.serde.common.dataformat import DataFormat
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def test_dataformat_is_enum():
|
|
7
|
+
"""Test DataFormat is an Enum"""
|
|
8
|
+
from enum import Enum
|
|
9
|
+
|
|
10
|
+
assert issubclass(DataFormat, Enum)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def test_dataformat_is_str_enum():
|
|
14
|
+
"""Test DataFormat inherits from str"""
|
|
15
|
+
assert issubclass(DataFormat, str)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def test_dataformat_has_parquet():
|
|
19
|
+
"""Test DataFormat has PARQUET attribute"""
|
|
20
|
+
assert hasattr(DataFormat, "PARQUET")
|
|
21
|
+
assert DataFormat.PARQUET == "parquet"
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def test_dataformat_has_csv():
|
|
25
|
+
"""Test DataFormat has CSV attribute"""
|
|
26
|
+
assert hasattr(DataFormat, "CSV")
|
|
27
|
+
assert DataFormat.CSV == "csv"
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def test_dataformat_has_json():
|
|
31
|
+
"""Test DataFormat has JSON attribute"""
|
|
32
|
+
assert hasattr(DataFormat, "JSON")
|
|
33
|
+
assert DataFormat.JSON == "json"
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def test_dataformat_values_are_lowercase():
|
|
37
|
+
"""Test all DataFormat values are lowercase"""
|
|
38
|
+
for fmt in DataFormat:
|
|
39
|
+
assert fmt.value == fmt.value.lower()
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def test_dataformat_has_three_members():
|
|
43
|
+
"""Test DataFormat has exactly three members"""
|
|
44
|
+
members = list(DataFormat)
|
|
45
|
+
assert len(members) == 3
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
# ==================== from_str() Method Tests ====================
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
def test_from_str_parquet_lowercase():
|
|
52
|
+
"""Test from_str with lowercase 'parquet'"""
|
|
53
|
+
fmt = DataFormat.from_str("parquet")
|
|
54
|
+
|
|
55
|
+
assert fmt == DataFormat.PARQUET
|
|
56
|
+
assert isinstance(fmt, DataFormat)
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
def test_from_str_parquet_uppercase():
|
|
60
|
+
"""Test from_str with uppercase 'PARQUET'"""
|
|
61
|
+
fmt = DataFormat.from_str("PARQUET")
|
|
62
|
+
|
|
63
|
+
assert fmt == DataFormat.PARQUET
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
def test_from_str_parquet_mixed_case():
|
|
67
|
+
"""Test from_str with mixed case 'PaRqUeT'"""
|
|
68
|
+
fmt = DataFormat.from_str("PaRqUeT")
|
|
69
|
+
|
|
70
|
+
assert fmt == DataFormat.PARQUET
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
def test_from_str_csv_lowercase():
|
|
74
|
+
"""Test from_str with lowercase 'csv'"""
|
|
75
|
+
fmt = DataFormat.from_str("csv")
|
|
76
|
+
|
|
77
|
+
assert fmt == DataFormat.CSV
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
def test_from_str_csv_uppercase():
|
|
81
|
+
"""Test from_str with uppercase 'CSV'"""
|
|
82
|
+
fmt = DataFormat.from_str("CSV")
|
|
83
|
+
|
|
84
|
+
assert fmt == DataFormat.CSV
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
def test_from_str_csv_mixed_case():
|
|
88
|
+
"""Test from_str with mixed case 'CsV'"""
|
|
89
|
+
fmt = DataFormat.from_str("CsV")
|
|
90
|
+
|
|
91
|
+
assert fmt == DataFormat.CSV
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
def test_from_str_json_lowercase():
|
|
95
|
+
"""Test from_str with lowercase 'json'"""
|
|
96
|
+
fmt = DataFormat.from_str("json")
|
|
97
|
+
|
|
98
|
+
assert fmt == DataFormat.JSON
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
def test_from_str_json_uppercase():
|
|
102
|
+
"""Test from_str with uppercase 'JSON'"""
|
|
103
|
+
fmt = DataFormat.from_str("JSON")
|
|
104
|
+
|
|
105
|
+
assert fmt == DataFormat.JSON
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
def test_from_str_json_mixed_case():
|
|
109
|
+
"""Test from_str with mixed case 'JsOn'"""
|
|
110
|
+
fmt = DataFormat.from_str("JsOn")
|
|
111
|
+
|
|
112
|
+
assert fmt == DataFormat.JSON
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
def test_from_str_invalid_format_raises_error():
|
|
116
|
+
"""Test from_str raises ValueError for invalid format"""
|
|
117
|
+
with pytest.raises(ValueError, match="Unknown DataFormat: xml"):
|
|
118
|
+
DataFormat.from_str("xml")
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
def test_from_str_empty_string_raises_error():
|
|
122
|
+
"""Test from_str raises ValueError for empty string"""
|
|
123
|
+
with pytest.raises(ValueError, match="Unknown DataFormat"):
|
|
124
|
+
DataFormat.from_str("")
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
def test_from_str_unknown_format_raises_error():
|
|
128
|
+
"""Test from_str raises ValueError for unknown formats"""
|
|
129
|
+
invalid_formats = ["txt", "xlsx", "pdf", "binary", "yaml", "toml"]
|
|
130
|
+
|
|
131
|
+
for invalid in invalid_formats:
|
|
132
|
+
with pytest.raises(ValueError, match=f"Unknown DataFormat: {invalid}"):
|
|
133
|
+
DataFormat.from_str(invalid)
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
def test_from_str_with_whitespace():
|
|
137
|
+
"""Test from_str does not strip whitespace (should fail)"""
|
|
138
|
+
with pytest.raises(ValueError):
|
|
139
|
+
DataFormat.from_str(" parquet ")
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
def test_from_str_numeric_string():
|
|
143
|
+
"""Test from_str with numeric string raises error"""
|
|
144
|
+
with pytest.raises(ValueError):
|
|
145
|
+
DataFormat.from_str("123")
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
# ==================== from_any() Method Tests ====================
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
def test_from_any_with_enum():
|
|
152
|
+
"""Test from_any with DataFormat enum instance"""
|
|
153
|
+
fmt = DataFormat.from_any(DataFormat.PARQUET)
|
|
154
|
+
|
|
155
|
+
assert fmt == DataFormat.PARQUET
|
|
156
|
+
assert isinstance(fmt, DataFormat)
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
def test_from_any_with_string_lowercase():
|
|
160
|
+
"""Test from_any with lowercase string"""
|
|
161
|
+
fmt = DataFormat.from_any("csv")
|
|
162
|
+
|
|
163
|
+
assert fmt == DataFormat.CSV
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
def test_from_any_with_string_uppercase():
|
|
167
|
+
"""Test from_any with uppercase string"""
|
|
168
|
+
fmt = DataFormat.from_any("JSON")
|
|
169
|
+
|
|
170
|
+
assert fmt == DataFormat.JSON
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
def test_from_any_with_string_mixed_case():
|
|
174
|
+
"""Test from_any with mixed case string"""
|
|
175
|
+
fmt = DataFormat.from_any("PaRqUeT")
|
|
176
|
+
|
|
177
|
+
assert fmt == DataFormat.PARQUET
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
def test_from_any_returns_same_instance():
|
|
181
|
+
"""Test from_any returns same instance for enum input"""
|
|
182
|
+
original = DataFormat.CSV
|
|
183
|
+
result = DataFormat.from_any(original)
|
|
184
|
+
|
|
185
|
+
assert result is original
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
def test_from_any_with_invalid_string():
|
|
189
|
+
"""Test from_any raises ValueError for invalid string"""
|
|
190
|
+
with pytest.raises(ValueError, match="Unknown DataFormat"):
|
|
191
|
+
DataFormat.from_any("invalid")
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
def test_from_any_all_formats():
|
|
195
|
+
"""Test from_any with all valid format strings"""
|
|
196
|
+
test_cases = [
|
|
197
|
+
("parquet", DataFormat.PARQUET),
|
|
198
|
+
("PARQUET", DataFormat.PARQUET),
|
|
199
|
+
("csv", DataFormat.CSV),
|
|
200
|
+
("CSV", DataFormat.CSV),
|
|
201
|
+
("json", DataFormat.JSON),
|
|
202
|
+
("JSON", DataFormat.JSON),
|
|
203
|
+
]
|
|
204
|
+
|
|
205
|
+
for input_str, expected in test_cases:
|
|
206
|
+
result = DataFormat.from_any(input_str)
|
|
207
|
+
assert result == expected
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
def test_from_any_with_enum_instances():
|
|
211
|
+
"""Test from_any with all enum instances"""
|
|
212
|
+
for fmt in DataFormat:
|
|
213
|
+
result = DataFormat.from_any(fmt)
|
|
214
|
+
assert result == fmt
|
|
215
|
+
assert result is fmt
|
|
216
|
+
|
|
217
|
+
|
|
218
|
+
# ==================== list_all() Method Tests ====================
|
|
219
|
+
|
|
220
|
+
|
|
221
|
+
def test_list_all_returns_list():
|
|
222
|
+
"""Test list_all returns a list"""
|
|
223
|
+
result = DataFormat.list_all()
|
|
224
|
+
|
|
225
|
+
assert isinstance(result, list)
|
|
226
|
+
|
|
227
|
+
|
|
228
|
+
def test_list_all_returns_all_formats():
|
|
229
|
+
"""Test list_all returns all DataFormat instances"""
|
|
230
|
+
result = DataFormat.list_all()
|
|
231
|
+
|
|
232
|
+
assert len(result) == 3
|
|
233
|
+
assert DataFormat.PARQUET in result
|
|
234
|
+
assert DataFormat.CSV in result
|
|
235
|
+
assert DataFormat.JSON in result
|
|
236
|
+
|
|
237
|
+
|
|
238
|
+
def test_list_all_contains_dataformat_instances():
|
|
239
|
+
"""Test list_all contains only DataFormat instances"""
|
|
240
|
+
result = DataFormat.list_all()
|
|
241
|
+
|
|
242
|
+
for item in result:
|
|
243
|
+
assert isinstance(item, DataFormat)
|
|
244
|
+
|
|
245
|
+
|
|
246
|
+
def test_list_all_order():
|
|
247
|
+
"""Test list_all returns formats in definition order"""
|
|
248
|
+
result = DataFormat.list_all()
|
|
249
|
+
|
|
250
|
+
assert result[0] == DataFormat.PARQUET
|
|
251
|
+
assert result[1] == DataFormat.CSV
|
|
252
|
+
assert result[2] == DataFormat.JSON
|
|
253
|
+
|
|
254
|
+
|
|
255
|
+
def test_list_all_is_complete():
|
|
256
|
+
"""Test list_all matches manual iteration"""
|
|
257
|
+
list_result = DataFormat.list_all()
|
|
258
|
+
manual_list = [fmt for fmt in DataFormat]
|
|
259
|
+
|
|
260
|
+
assert list_result == manual_list
|
|
261
|
+
|
|
262
|
+
|
|
263
|
+
# ==================== __str__() Method Tests ====================
|
|
264
|
+
|
|
265
|
+
|
|
266
|
+
def test_str_parquet():
|
|
267
|
+
"""Test __str__ for PARQUET format"""
|
|
268
|
+
result = str(DataFormat.PARQUET)
|
|
269
|
+
|
|
270
|
+
assert result == "parquet"
|
|
271
|
+
assert isinstance(result, str)
|
|
272
|
+
|
|
273
|
+
|
|
274
|
+
def test_str_csv():
|
|
275
|
+
"""Test __str__ for CSV format"""
|
|
276
|
+
result = str(DataFormat.CSV)
|
|
277
|
+
|
|
278
|
+
assert result == "csv"
|
|
279
|
+
|
|
280
|
+
|
|
281
|
+
def test_str_json():
|
|
282
|
+
"""Test __str__ for JSON format"""
|
|
283
|
+
result = str(DataFormat.JSON)
|
|
284
|
+
|
|
285
|
+
assert result == "json"
|
|
286
|
+
|
|
287
|
+
|
|
288
|
+
def test_str_all_formats():
|
|
289
|
+
"""Test __str__ for all formats returns value"""
|
|
290
|
+
for fmt in DataFormat:
|
|
291
|
+
result = str(fmt)
|
|
292
|
+
assert result == fmt.value
|
|
293
|
+
|
|
294
|
+
|
|
295
|
+
def test_str_in_f_string():
|
|
296
|
+
"""Test DataFormat works in f-strings"""
|
|
297
|
+
fmt = DataFormat.PARQUET
|
|
298
|
+
result = f"Format is {fmt}"
|
|
299
|
+
|
|
300
|
+
assert result == "Format is parquet"
|
|
301
|
+
|
|
302
|
+
|
|
303
|
+
def test_str_in_format():
|
|
304
|
+
"""Test DataFormat works with .format()"""
|
|
305
|
+
fmt = DataFormat.CSV
|
|
306
|
+
result = "Format is {}".format(fmt)
|
|
307
|
+
|
|
308
|
+
assert result == "Format is csv"
|
|
309
|
+
|
|
310
|
+
|
|
311
|
+
# ==================== __repr__() Method Tests ====================
|
|
312
|
+
|
|
313
|
+
|
|
314
|
+
def test_repr_parquet():
|
|
315
|
+
"""Test __repr__ for PARQUET format"""
|
|
316
|
+
result = repr(DataFormat.PARQUET)
|
|
317
|
+
|
|
318
|
+
assert result == "DataFormat.PARQUET"
|
|
319
|
+
|
|
320
|
+
|
|
321
|
+
def test_repr_csv():
|
|
322
|
+
"""Test __repr__ for CSV format"""
|
|
323
|
+
result = repr(DataFormat.CSV)
|
|
324
|
+
|
|
325
|
+
assert result == "DataFormat.CSV"
|
|
326
|
+
|
|
327
|
+
|
|
328
|
+
def test_repr_json():
|
|
329
|
+
"""Test __repr__ for JSON format"""
|
|
330
|
+
result = repr(DataFormat.JSON)
|
|
331
|
+
|
|
332
|
+
assert result == "DataFormat.JSON"
|
|
333
|
+
|
|
334
|
+
|
|
335
|
+
def test_repr_all_formats():
|
|
336
|
+
"""Test __repr__ for all formats"""
|
|
337
|
+
test_cases = [
|
|
338
|
+
(DataFormat.PARQUET, "DataFormat.PARQUET"),
|
|
339
|
+
(DataFormat.CSV, "DataFormat.CSV"),
|
|
340
|
+
(DataFormat.JSON, "DataFormat.JSON"),
|
|
341
|
+
]
|
|
342
|
+
|
|
343
|
+
for fmt, expected in test_cases:
|
|
344
|
+
assert repr(fmt) == expected
|
|
345
|
+
|
|
346
|
+
|
|
347
|
+
def test_repr_contains_class_name():
|
|
348
|
+
"""Test __repr__ contains class name"""
|
|
349
|
+
for fmt in DataFormat:
|
|
350
|
+
result = repr(fmt)
|
|
351
|
+
assert "DataFormat" in result
|
|
352
|
+
|
|
353
|
+
|
|
354
|
+
def test_repr_contains_member_name():
|
|
355
|
+
"""Test __repr__ contains member name"""
|
|
356
|
+
assert "PARQUET" in repr(DataFormat.PARQUET)
|
|
357
|
+
assert "CSV" in repr(DataFormat.CSV)
|
|
358
|
+
assert "JSON" in repr(DataFormat.JSON)
|
|
359
|
+
|
|
360
|
+
|
|
361
|
+
# ==================== String Comparison Tests ====================
|
|
362
|
+
|
|
363
|
+
|
|
364
|
+
def test_equals_string_lowercase():
|
|
365
|
+
"""Test DataFormat equals lowercase string"""
|
|
366
|
+
assert DataFormat.PARQUET == "parquet"
|
|
367
|
+
assert DataFormat.CSV == "csv"
|
|
368
|
+
assert DataFormat.JSON == "json"
|
|
369
|
+
|
|
370
|
+
|
|
371
|
+
def test_not_equals_uppercase_string():
|
|
372
|
+
"""Test DataFormat does not equal uppercase string directly"""
|
|
373
|
+
# Since DataFormat inherits from str, it compares values directly
|
|
374
|
+
assert DataFormat.PARQUET != "PARQUET"
|
|
375
|
+
assert DataFormat.CSV != "CSV"
|
|
376
|
+
assert DataFormat.JSON != "JSON"
|
|
377
|
+
|
|
378
|
+
|
|
379
|
+
def test_equals_another_enum_instance():
|
|
380
|
+
"""Test DataFormat equals another instance of same value"""
|
|
381
|
+
fmt1 = DataFormat.PARQUET
|
|
382
|
+
fmt2 = DataFormat.PARQUET
|
|
383
|
+
|
|
384
|
+
assert fmt1 == fmt2
|
|
385
|
+
assert fmt1 is fmt2 # Same instance
|
|
386
|
+
|
|
387
|
+
|
|
388
|
+
def test_not_equals_different_format():
|
|
389
|
+
"""Test DataFormat not equals different format"""
|
|
390
|
+
assert DataFormat.PARQUET != DataFormat.CSV
|
|
391
|
+
assert DataFormat.CSV != DataFormat.JSON
|
|
392
|
+
assert DataFormat.JSON != DataFormat.PARQUET
|
|
393
|
+
|
|
394
|
+
|
|
395
|
+
def test_in_operator_with_list():
|
|
396
|
+
"""Test DataFormat with 'in' operator"""
|
|
397
|
+
formats = [DataFormat.PARQUET, DataFormat.CSV]
|
|
398
|
+
|
|
399
|
+
assert DataFormat.PARQUET in formats
|
|
400
|
+
assert DataFormat.JSON not in formats
|
|
401
|
+
|
|
402
|
+
|
|
403
|
+
def test_in_operator_with_strings():
|
|
404
|
+
"""Test DataFormat value in string list"""
|
|
405
|
+
strings = ["parquet", "csv"]
|
|
406
|
+
|
|
407
|
+
assert DataFormat.PARQUET in strings
|
|
408
|
+
assert DataFormat.JSON not in strings
|
|
409
|
+
|
|
410
|
+
|
|
411
|
+
# ==================== Enum Iteration Tests ====================
|
|
412
|
+
|
|
413
|
+
|
|
414
|
+
def test_iterate_all_formats():
|
|
415
|
+
"""Test iterating over DataFormat"""
|
|
416
|
+
formats = []
|
|
417
|
+
for fmt in DataFormat:
|
|
418
|
+
formats.append(fmt)
|
|
419
|
+
|
|
420
|
+
assert len(formats) == 3
|
|
421
|
+
assert DataFormat.PARQUET in formats
|
|
422
|
+
assert DataFormat.CSV in formats
|
|
423
|
+
assert DataFormat.JSON in formats
|
|
424
|
+
|
|
425
|
+
|
|
426
|
+
def test_list_conversion():
|
|
427
|
+
"""Test converting DataFormat to list"""
|
|
428
|
+
formats_list = list(DataFormat)
|
|
429
|
+
|
|
430
|
+
assert isinstance(formats_list, list)
|
|
431
|
+
assert len(formats_list) == 3
|
|
432
|
+
|
|
433
|
+
|
|
434
|
+
def test_enum_members_are_unique():
|
|
435
|
+
"""Test all DataFormat members are unique"""
|
|
436
|
+
members = list(DataFormat)
|
|
437
|
+
values = [fmt.value for fmt in members]
|
|
438
|
+
|
|
439
|
+
assert len(values) == len(set(values))
|
|
440
|
+
|
|
441
|
+
|
|
442
|
+
# ==================== Type Checking Tests ====================
|
|
443
|
+
|
|
444
|
+
|
|
445
|
+
def test_isinstance_dataformat():
|
|
446
|
+
"""Test isinstance check for DataFormat"""
|
|
447
|
+
fmt = DataFormat.PARQUET
|
|
448
|
+
|
|
449
|
+
assert isinstance(fmt, DataFormat)
|
|
450
|
+
|
|
451
|
+
|
|
452
|
+
def test_isinstance_str():
|
|
453
|
+
"""Test DataFormat instance is also a str"""
|
|
454
|
+
fmt = DataFormat.CSV
|
|
455
|
+
|
|
456
|
+
assert isinstance(fmt, str)
|
|
457
|
+
|
|
458
|
+
|
|
459
|
+
def test_isinstance_enum():
|
|
460
|
+
"""Test DataFormat instance is also an Enum"""
|
|
461
|
+
from enum import Enum
|
|
462
|
+
|
|
463
|
+
fmt = DataFormat.JSON
|
|
464
|
+
|
|
465
|
+
assert isinstance(fmt, Enum)
|
|
466
|
+
|
|
467
|
+
|
|
468
|
+
def test_type_of_format():
|
|
469
|
+
"""Test type() returns DataFormat"""
|
|
470
|
+
fmt = DataFormat.PARQUET
|
|
471
|
+
|
|
472
|
+
assert type(fmt) is DataFormat
|
|
473
|
+
|
|
474
|
+
|
|
475
|
+
# ==================== Value Access Tests ====================
|
|
476
|
+
|
|
477
|
+
|
|
478
|
+
def test_access_value_attribute():
|
|
479
|
+
"""Test accessing .value attribute"""
|
|
480
|
+
assert DataFormat.PARQUET.value == "parquet"
|
|
481
|
+
assert DataFormat.CSV.value == "csv"
|
|
482
|
+
assert DataFormat.JSON.value == "json"
|
|
483
|
+
|
|
484
|
+
|
|
485
|
+
def test_access_name_attribute():
|
|
486
|
+
"""Test accessing .name attribute"""
|
|
487
|
+
assert DataFormat.PARQUET.name == "PARQUET"
|
|
488
|
+
assert DataFormat.CSV.name == "CSV"
|
|
489
|
+
assert DataFormat.JSON.name == "JSON"
|
|
490
|
+
|
|
491
|
+
|
|
492
|
+
def test_name_attribute_is_uppercase():
|
|
493
|
+
"""Test .name attribute is uppercase"""
|
|
494
|
+
for fmt in DataFormat:
|
|
495
|
+
assert fmt.name == fmt.name.upper()
|
|
496
|
+
|
|
497
|
+
|
|
498
|
+
def test_value_and_str_are_same():
|
|
499
|
+
"""Test .value and str() return same result"""
|
|
500
|
+
for fmt in DataFormat:
|
|
501
|
+
assert fmt.value == str(fmt)
|
|
502
|
+
|
|
503
|
+
|
|
504
|
+
# ==================== Dictionary and Set Operations ====================
|
|
505
|
+
|
|
506
|
+
|
|
507
|
+
def test_dataformat_as_dict_key():
|
|
508
|
+
"""Test using DataFormat as dictionary key"""
|
|
509
|
+
mapping = {
|
|
510
|
+
DataFormat.PARQUET: "parquet_handler",
|
|
511
|
+
DataFormat.CSV: "csv_handler",
|
|
512
|
+
DataFormat.JSON: "json_handler",
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
assert mapping[DataFormat.PARQUET] == "parquet_handler"
|
|
516
|
+
assert mapping[DataFormat.CSV] == "csv_handler"
|
|
517
|
+
assert mapping[DataFormat.JSON] == "json_handler"
|
|
518
|
+
|
|
519
|
+
|
|
520
|
+
def test_dataformat_in_set():
|
|
521
|
+
"""Test DataFormat in set operations"""
|
|
522
|
+
formats_set = {DataFormat.PARQUET, DataFormat.CSV, DataFormat.CSV}
|
|
523
|
+
|
|
524
|
+
assert len(formats_set) == 2 # Duplicate removed
|
|
525
|
+
assert DataFormat.PARQUET in formats_set
|
|
526
|
+
assert DataFormat.CSV in formats_set
|
|
527
|
+
assert DataFormat.JSON not in formats_set
|
|
528
|
+
|
|
529
|
+
|
|
530
|
+
def test_dataformat_hashable():
|
|
531
|
+
"""Test DataFormat is hashable"""
|
|
532
|
+
# Should not raise
|
|
533
|
+
hash(DataFormat.PARQUET)
|
|
534
|
+
hash(DataFormat.CSV)
|
|
535
|
+
hash(DataFormat.JSON)
|
|
536
|
+
|
|
537
|
+
|
|
538
|
+
# ==================== Edge Cases and Error Handling ====================
|
|
539
|
+
|
|
540
|
+
|
|
541
|
+
def test_from_str_case_variations():
|
|
542
|
+
"""Test from_str with various case combinations"""
|
|
543
|
+
variations = [
|
|
544
|
+
"parquet",
|
|
545
|
+
"PARQUET",
|
|
546
|
+
"Parquet",
|
|
547
|
+
"pArQuEt",
|
|
548
|
+
"ParQueT",
|
|
549
|
+
]
|
|
550
|
+
|
|
551
|
+
for variant in variations:
|
|
552
|
+
result = DataFormat.from_str(variant)
|
|
553
|
+
assert result == DataFormat.PARQUET
|
|
554
|
+
|
|
555
|
+
|
|
556
|
+
def test_from_str_special_characters_raises_error():
|
|
557
|
+
"""Test from_str with special characters raises error"""
|
|
558
|
+
invalid_inputs = ["parquet!", "csv#", "json@", "par-quet", "c_sv"]
|
|
559
|
+
|
|
560
|
+
for invalid in invalid_inputs:
|
|
561
|
+
with pytest.raises(ValueError):
|
|
562
|
+
DataFormat.from_str(invalid)
|
|
563
|
+
|
|
564
|
+
|
|
565
|
+
def test_from_any_type_error_for_invalid_type():
|
|
566
|
+
"""Test from_any behavior with invalid type (should raise ValueError in from_str)"""
|
|
567
|
+
# from_any expects DataFormat or str, passing int will fail when calling from_str
|
|
568
|
+
with pytest.raises(AttributeError): # int doesn't have .lower()
|
|
569
|
+
DataFormat.from_any(123)
|
|
570
|
+
|
|
571
|
+
|
|
572
|
+
def test_comparison_with_none():
|
|
573
|
+
"""Test DataFormat comparison with None"""
|
|
574
|
+
assert DataFormat.PARQUET is not None
|
|
575
|
+
|
|
576
|
+
|
|
577
|
+
def test_boolean_context():
|
|
578
|
+
"""Test DataFormat in boolean context"""
|
|
579
|
+
# All enum members are truthy
|
|
580
|
+
assert bool(DataFormat.PARQUET)
|
|
581
|
+
assert bool(DataFormat.CSV)
|
|
582
|
+
assert bool(DataFormat.JSON)
|
|
583
|
+
|
|
584
|
+
|
|
585
|
+
# ==================== Integration Tests ====================
|
|
586
|
+
|
|
587
|
+
|
|
588
|
+
def test_roundtrip_str_to_enum_to_str():
|
|
589
|
+
"""Test round trip conversion string -> enum -> string"""
|
|
590
|
+
original = "parquet"
|
|
591
|
+
fmt = DataFormat.from_str(original)
|
|
592
|
+
result = str(fmt)
|
|
593
|
+
|
|
594
|
+
assert result == original
|
|
595
|
+
|
|
596
|
+
|
|
597
|
+
def test_from_any_roundtrip():
|
|
598
|
+
"""Test from_any roundtrip with string and enum"""
|
|
599
|
+
# String -> Enum -> Same Enum
|
|
600
|
+
fmt1 = DataFormat.from_any("csv")
|
|
601
|
+
fmt2 = DataFormat.from_any(fmt1)
|
|
602
|
+
|
|
603
|
+
assert fmt1 == fmt2
|
|
604
|
+
assert fmt1 is fmt2
|
|
605
|
+
|
|
606
|
+
|
|
607
|
+
def test_all_formats_work_with_all_methods():
|
|
608
|
+
"""Test all formats work with all methods"""
|
|
609
|
+
for fmt in DataFormat:
|
|
610
|
+
# from_any
|
|
611
|
+
assert DataFormat.from_any(fmt) == fmt
|
|
612
|
+
|
|
613
|
+
# from_str
|
|
614
|
+
assert DataFormat.from_str(fmt.value) == fmt
|
|
615
|
+
|
|
616
|
+
# __str__
|
|
617
|
+
assert str(fmt) == fmt.value
|
|
618
|
+
|
|
619
|
+
# __repr__
|
|
620
|
+
assert "DataFormat" in repr(fmt)
|
|
621
|
+
|
|
622
|
+
|
|
623
|
+
def test_format_usage_in_conditional():
|
|
624
|
+
"""Test using DataFormat in conditional statements"""
|
|
625
|
+
|
|
626
|
+
def process_format(fmt: DataFormat) -> str:
|
|
627
|
+
if fmt == DataFormat.PARQUET:
|
|
628
|
+
return "parquet_processor"
|
|
629
|
+
elif fmt == DataFormat.CSV:
|
|
630
|
+
return "csv_processor"
|
|
631
|
+
elif fmt == DataFormat.JSON:
|
|
632
|
+
return "json_processor"
|
|
633
|
+
else:
|
|
634
|
+
return "unknown"
|
|
635
|
+
|
|
636
|
+
assert process_format(DataFormat.PARQUET) == "parquet_processor"
|
|
637
|
+
assert process_format(DataFormat.CSV) == "csv_processor"
|
|
638
|
+
assert process_format(DataFormat.JSON) == "json_processor"
|
|
639
|
+
|
|
640
|
+
|
|
641
|
+
def test_format_matching_with_string():
|
|
642
|
+
"""Test format matching with string values"""
|
|
643
|
+
|
|
644
|
+
def get_extension(fmt: DataFormat) -> str:
|
|
645
|
+
extensions = {
|
|
646
|
+
"parquet": ".parquet",
|
|
647
|
+
"csv": ".csv",
|
|
648
|
+
"json": ".json",
|
|
649
|
+
}
|
|
650
|
+
return extensions.get(str(fmt), ".unknown")
|
|
651
|
+
|
|
652
|
+
assert get_extension(DataFormat.PARQUET) == ".parquet"
|
|
653
|
+
assert get_extension(DataFormat.CSV) == ".csv"
|
|
654
|
+
assert get_extension(DataFormat.JSON) == ".json"
|
|
655
|
+
|
|
656
|
+
|
|
657
|
+
# ==================== String Method Tests ====================
|
|
658
|
+
|
|
659
|
+
|
|
660
|
+
def test_format_upper():
|
|
661
|
+
"""Test calling .upper() on DataFormat (as it inherits from str)"""
|
|
662
|
+
result = DataFormat.PARQUET.upper()
|
|
663
|
+
|
|
664
|
+
assert result == "PARQUET"
|
|
665
|
+
assert isinstance(result, str)
|
|
666
|
+
|
|
667
|
+
|
|
668
|
+
def test_format_lower():
|
|
669
|
+
"""Test calling .lower() on DataFormat"""
|
|
670
|
+
result = DataFormat.CSV.lower()
|
|
671
|
+
|
|
672
|
+
assert result == "csv"
|
|
673
|
+
|
|
674
|
+
|
|
675
|
+
def test_format_startswith():
|
|
676
|
+
"""Test calling .startswith() on DataFormat"""
|
|
677
|
+
assert DataFormat.PARQUET.startswith("par")
|
|
678
|
+
assert DataFormat.CSV.startswith("c")
|
|
679
|
+
assert DataFormat.JSON.startswith("js")
|
|
680
|
+
|
|
681
|
+
|
|
682
|
+
def test_format_endswith():
|
|
683
|
+
"""Test calling .endswith() on DataFormat"""
|
|
684
|
+
assert DataFormat.PARQUET.endswith("quet")
|
|
685
|
+
assert DataFormat.CSV.endswith("sv")
|
|
686
|
+
assert DataFormat.JSON.endswith("son")
|
|
687
|
+
|
|
688
|
+
|
|
689
|
+
def test_format_in_string():
|
|
690
|
+
"""Test DataFormat in string operations"""
|
|
691
|
+
text = "The format is parquet"
|
|
692
|
+
|
|
693
|
+
assert DataFormat.PARQUET in text
|
|
694
|
+
assert str(DataFormat.PARQUET) in text
|