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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""TMX fetchers tests."""
|
| 2 |
+
|
| 3 |
+
from datetime import date
|
| 4 |
+
|
| 5 |
+
import pytest
|
| 6 |
+
from openbb_core.app.service.user_service import UserService
|
| 7 |
+
from openbb_tmx.models.available_indices import TmxAvailableIndicesFetcher
|
| 8 |
+
from openbb_tmx.models.bond_prices import TmxBondPricesFetcher
|
| 9 |
+
from openbb_tmx.models.calendar_earnings import TmxCalendarEarningsFetcher
|
| 10 |
+
from openbb_tmx.models.company_filings import TmxCompanyFilingsFetcher
|
| 11 |
+
from openbb_tmx.models.company_news import TmxCompanyNewsFetcher
|
| 12 |
+
from openbb_tmx.models.equity_historical import TmxEquityHistoricalFetcher
|
| 13 |
+
from openbb_tmx.models.equity_profile import TmxEquityProfileFetcher
|
| 14 |
+
from openbb_tmx.models.equity_quote import TmxEquityQuoteFetcher
|
| 15 |
+
from openbb_tmx.models.equity_search import TmxEquitySearchFetcher
|
| 16 |
+
from openbb_tmx.models.etf_countries import TmxEtfCountriesFetcher
|
| 17 |
+
from openbb_tmx.models.etf_holdings import TmxEtfHoldingsFetcher
|
| 18 |
+
from openbb_tmx.models.etf_info import TmxEtfInfoFetcher
|
| 19 |
+
from openbb_tmx.models.etf_search import TmxEtfSearchFetcher
|
| 20 |
+
from openbb_tmx.models.etf_sectors import TmxEtfSectorsFetcher
|
| 21 |
+
from openbb_tmx.models.gainers import TmxGainersFetcher
|
| 22 |
+
from openbb_tmx.models.historical_dividends import TmxHistoricalDividendsFetcher
|
| 23 |
+
from openbb_tmx.models.index_constituents import TmxIndexConstituentsFetcher
|
| 24 |
+
from openbb_tmx.models.index_sectors import TmxIndexSectorsFetcher
|
| 25 |
+
from openbb_tmx.models.index_snapshots import TmxIndexSnapshotsFetcher
|
| 26 |
+
from openbb_tmx.models.insider_trading import TmxInsiderTradingFetcher
|
| 27 |
+
from openbb_tmx.models.options_chains import TmxOptionsChainsFetcher
|
| 28 |
+
from openbb_tmx.models.price_target_consensus import TmxPriceTargetConsensusFetcher
|
| 29 |
+
from openbb_tmx.models.treasury_prices import TmxTreasuryPricesFetcher
|
| 30 |
+
|
| 31 |
+
test_credentials = UserService().default_user_settings.credentials.model_dump()
|
| 32 |
+
|
| 33 |
+
|
| 34 |
+
@pytest.fixture(scope="module")
|
| 35 |
+
def vcr_config():
|
| 36 |
+
"""VCR configuration."""
|
| 37 |
+
return {
|
| 38 |
+
"filter_headers": [("User-Agent", None)],
|
| 39 |
+
"filter_query_parameters": [
|
| 40 |
+
None,
|
| 41 |
+
],
|
| 42 |
+
}
|
| 43 |
+
|
| 44 |
+
|
| 45 |
+
@pytest.mark.record_http
|
| 46 |
+
def test_tmx_equity_profile_fetcher(credentials=test_credentials):
|
| 47 |
+
"""Test equity profile fetcher."""
|
| 48 |
+
params = {"symbol": "RY,NTR"}
|
| 49 |
+
|
| 50 |
+
fetcher = TmxEquityProfileFetcher()
|
| 51 |
+
result = fetcher.test(params, credentials)
|
| 52 |
+
assert result is None
|
| 53 |
+
|
| 54 |
+
|
| 55 |
+
@pytest.mark.record_http
|
| 56 |
+
def test_tmx_equity_search_fetcher(credentials=test_credentials):
|
| 57 |
+
"""Test equity search fetcher."""
|
| 58 |
+
params = {"query": "gold", "use_cache": False}
|
| 59 |
+
|
| 60 |
+
fetcher = TmxEquitySearchFetcher()
|
| 61 |
+
result = fetcher.test(params, credentials)
|
| 62 |
+
assert result is None
|
| 63 |
+
|
| 64 |
+
|
| 65 |
+
@pytest.mark.record_http
|
| 66 |
+
def test_tmx_available_indices_fetcher(credentials=test_credentials):
|
| 67 |
+
"""Test available indices fetcher."""
|
| 68 |
+
params = {"use_cache": False}
|
| 69 |
+
|
| 70 |
+
fetcher = TmxAvailableIndicesFetcher()
|
| 71 |
+
result = fetcher.test(params, credentials)
|
| 72 |
+
assert result is None
|
| 73 |
+
|
| 74 |
+
|
| 75 |
+
@pytest.mark.record_http
|
| 76 |
+
def test_tmx_calendar_earnings_fetcher(credentials=test_credentials):
|
| 77 |
+
"""Test calendar earnings fetcher."""
|
| 78 |
+
params = {"start_date": date(2023, 1, 2), "end_date": date(2023, 1, 31)}
|
| 79 |
+
|
| 80 |
+
fetcher = TmxCalendarEarningsFetcher()
|
| 81 |
+
result = fetcher.test(params, credentials)
|
| 82 |
+
assert result is None
|
| 83 |
+
|
| 84 |
+
|
| 85 |
+
@pytest.mark.record_http
|
| 86 |
+
def test_tmx_company_filings_fetcher(credentials=test_credentials):
|
| 87 |
+
"""Test company filings fetcher."""
|
| 88 |
+
params = {
|
| 89 |
+
"symbol": "SHOP",
|
| 90 |
+
"start_date": date(2023, 6, 30),
|
| 91 |
+
"end_date": date(2023, 9, 30),
|
| 92 |
+
}
|
| 93 |
+
|
| 94 |
+
fetcher = TmxCompanyFilingsFetcher()
|
| 95 |
+
result = fetcher.test(params, credentials)
|
| 96 |
+
assert result is None
|
| 97 |
+
|
| 98 |
+
|
| 99 |
+
@pytest.mark.record_http
|
| 100 |
+
def test_tmx_company_news_fetcher(credentials=test_credentials):
|
| 101 |
+
"""Test company news fetcher."""
|
| 102 |
+
params = {"symbol": "SHOP", "limit": 5}
|
| 103 |
+
|
| 104 |
+
fetcher = TmxCompanyNewsFetcher()
|
| 105 |
+
result = fetcher.test(params, credentials)
|
| 106 |
+
assert result is None
|
| 107 |
+
|
| 108 |
+
|
| 109 |
+
@pytest.mark.record_http
|
| 110 |
+
def test_tmx_equity_historical_fetcher(credentials=test_credentials):
|
| 111 |
+
"""Test equity historical fetcher."""
|
| 112 |
+
params = {
|
| 113 |
+
"symbol": "SHOP",
|
| 114 |
+
"start_date": date(2022, 1, 1),
|
| 115 |
+
"end_date": date(2023, 1, 1),
|
| 116 |
+
}
|
| 117 |
+
|
| 118 |
+
fetcher = TmxEquityHistoricalFetcher()
|
| 119 |
+
result = fetcher.test(params, credentials)
|
| 120 |
+
assert result is None
|
| 121 |
+
|
| 122 |
+
|
| 123 |
+
@pytest.mark.record_http
|
| 124 |
+
def test_tmx_equity_quote_fetcher(credentials=test_credentials):
|
| 125 |
+
"""Test equity quote fetcher."""
|
| 126 |
+
params = {"symbol": "SHOP"}
|
| 127 |
+
|
| 128 |
+
fetcher = TmxEquityQuoteFetcher()
|
| 129 |
+
result = fetcher.test(params, credentials)
|
| 130 |
+
assert result is None
|
| 131 |
+
|
| 132 |
+
|
| 133 |
+
@pytest.mark.record_http
|
| 134 |
+
def test_tmx_etf_countries_fetcher(credentials=test_credentials):
|
| 135 |
+
"""Test ETF countries fetcher."""
|
| 136 |
+
params = {"symbol": "HXX", "use_cache": False}
|
| 137 |
+
|
| 138 |
+
fetcher = TmxEtfCountriesFetcher()
|
| 139 |
+
result = fetcher.test(params, credentials)
|
| 140 |
+
assert result is None
|
| 141 |
+
|
| 142 |
+
|
| 143 |
+
@pytest.mark.record_http
|
| 144 |
+
def test_tmx_etf_holdings_fetcher(credentials=test_credentials):
|
| 145 |
+
"""Test ETF holdings fetcher."""
|
| 146 |
+
params = {"symbol": "XIU", "use_cache": False}
|
| 147 |
+
|
| 148 |
+
fetcher = TmxEtfHoldingsFetcher()
|
| 149 |
+
result = fetcher.test(params, credentials)
|
| 150 |
+
assert result is None
|
| 151 |
+
|
| 152 |
+
|
| 153 |
+
@pytest.mark.record_http
|
| 154 |
+
def test_tmx_etf_info_fetcher(credentials=test_credentials):
|
| 155 |
+
"""Test ETF info fetcher."""
|
| 156 |
+
params = {"symbol": "XIU", "use_cache": False}
|
| 157 |
+
|
| 158 |
+
fetcher = TmxEtfInfoFetcher()
|
| 159 |
+
result = fetcher.test(params, credentials)
|
| 160 |
+
assert result is None
|
| 161 |
+
|
| 162 |
+
|
| 163 |
+
@pytest.mark.record_http
|
| 164 |
+
def test_tmx_etf_search_fetcher(credentials=test_credentials):
|
| 165 |
+
"""Test ETF search fetcher."""
|
| 166 |
+
params = {"query": "sector", "use_cache": False}
|
| 167 |
+
|
| 168 |
+
fetcher = TmxEtfSearchFetcher()
|
| 169 |
+
result = fetcher.test(params, credentials)
|
| 170 |
+
assert result is None
|
| 171 |
+
|
| 172 |
+
|
| 173 |
+
@pytest.mark.record_http
|
| 174 |
+
def test_tmx_etf_sectors_fetcher(credentials=test_credentials):
|
| 175 |
+
"""Test ETF sectors fetcher."""
|
| 176 |
+
params = {"symbol": "XIU", "use_cache": False}
|
| 177 |
+
|
| 178 |
+
fetcher = TmxEtfSectorsFetcher()
|
| 179 |
+
result = fetcher.test(params, credentials)
|
| 180 |
+
assert result is None
|
| 181 |
+
|
| 182 |
+
|
| 183 |
+
@pytest.mark.record_http
|
| 184 |
+
def test_tmx_gainers_fetcher(credentials=test_credentials):
|
| 185 |
+
"""Test gainers fetcher."""
|
| 186 |
+
params = {}
|
| 187 |
+
|
| 188 |
+
fetcher = TmxGainersFetcher()
|
| 189 |
+
result = fetcher.test(params, credentials)
|
| 190 |
+
assert result is None
|
| 191 |
+
|
| 192 |
+
|
| 193 |
+
@pytest.mark.record_http
|
| 194 |
+
def test_tmx_historical_dividends_fetcher(credentials=test_credentials):
|
| 195 |
+
"""Test historical dividends fetcher."""
|
| 196 |
+
params = {"symbol": "TD"}
|
| 197 |
+
|
| 198 |
+
fetcher = TmxHistoricalDividendsFetcher()
|
| 199 |
+
result = fetcher.test(params, credentials)
|
| 200 |
+
assert result is None
|
| 201 |
+
|
| 202 |
+
|
| 203 |
+
@pytest.mark.record_http
|
| 204 |
+
def test_tmx_index_constituents_fetcher(credentials=test_credentials):
|
| 205 |
+
"""Test index constituents fetcher."""
|
| 206 |
+
params = {"symbol": "^TX60", "use_cache": False}
|
| 207 |
+
|
| 208 |
+
fetcher = TmxIndexConstituentsFetcher()
|
| 209 |
+
result = fetcher.test(params, credentials)
|
| 210 |
+
assert result is None
|
| 211 |
+
|
| 212 |
+
|
| 213 |
+
@pytest.mark.record_http
|
| 214 |
+
def test_tmx_index_sectors_fetcher(credentials=test_credentials):
|
| 215 |
+
"""Test index sectors fetcher."""
|
| 216 |
+
params = {"symbol": "^TSX", "use_cache": False}
|
| 217 |
+
|
| 218 |
+
fetcher = TmxIndexSectorsFetcher()
|
| 219 |
+
result = fetcher.test(params, credentials)
|
| 220 |
+
assert result is None
|
| 221 |
+
|
| 222 |
+
|
| 223 |
+
@pytest.mark.record_http
|
| 224 |
+
def test_tmx_index_snapshots_fetcher(credentials=test_credentials):
|
| 225 |
+
"""Test index snapshots fetcher."""
|
| 226 |
+
params = {"use_cache": False}
|
| 227 |
+
|
| 228 |
+
fetcher = TmxIndexSnapshotsFetcher()
|
| 229 |
+
result = fetcher.test(params, credentials)
|
| 230 |
+
assert result is None
|
| 231 |
+
|
| 232 |
+
|
| 233 |
+
@pytest.mark.record_http
|
| 234 |
+
def test_tmx_insider_trading_fetcher(credentials=test_credentials):
|
| 235 |
+
"""Test insider trading fetcher."""
|
| 236 |
+
params = {"symbol": "SHOP", "summary": False}
|
| 237 |
+
|
| 238 |
+
fetcher = TmxInsiderTradingFetcher()
|
| 239 |
+
result = fetcher.test(params, credentials)
|
| 240 |
+
assert result is None
|
| 241 |
+
|
| 242 |
+
|
| 243 |
+
@pytest.mark.record_http
|
| 244 |
+
def test_tmx_options_chains_fetcher(credentials=test_credentials):
|
| 245 |
+
"""Test options chains fetcher."""
|
| 246 |
+
|
| 247 |
+
params = {"symbol": "SHOP", "use_cache": False, "date": date(2023, 9, 15)}
|
| 248 |
+
|
| 249 |
+
fetcher = TmxOptionsChainsFetcher()
|
| 250 |
+
result = fetcher.test(params, credentials)
|
| 251 |
+
assert result is None
|
| 252 |
+
|
| 253 |
+
|
| 254 |
+
@pytest.mark.record_http
|
| 255 |
+
def test_tmx_price_target_consensus_fetcher(credentials=test_credentials):
|
| 256 |
+
"""Test price target consensus fetcher."""
|
| 257 |
+
params = {"symbol": "SHOP"}
|
| 258 |
+
|
| 259 |
+
fetcher = TmxPriceTargetConsensusFetcher()
|
| 260 |
+
result = fetcher.test(params, credentials)
|
| 261 |
+
assert result is None
|
| 262 |
+
|
| 263 |
+
|
| 264 |
+
@pytest.mark.record_http
|
| 265 |
+
def test_tmx_treasury_prices_fetcher(credentials=test_credentials):
|
| 266 |
+
"""Test treasury prices fetcher."""
|
| 267 |
+
params = {"govt_type": "federal", "use_cache": False}
|
| 268 |
+
|
| 269 |
+
fetcher = TmxTreasuryPricesFetcher()
|
| 270 |
+
result = fetcher.test(params, credentials)
|
| 271 |
+
assert result is None
|
| 272 |
+
|
| 273 |
+
|
| 274 |
+
@pytest.mark.record_http
|
| 275 |
+
def test_tmx_bond_prices_fetcher(credentials=test_credentials):
|
| 276 |
+
"""Test bond prices fetcher."""
|
| 277 |
+
params = {"use_cache": False, "coupon_rate_min": 4}
|
| 278 |
+
|
| 279 |
+
fetcher = TmxBondPricesFetcher()
|
| 280 |
+
result = fetcher.test(params, credentials)
|
| 281 |
+
assert result is None
|