Refactor project structure to organize APIs (#24)

* Refactor project structure "api"
* fix bug conversione delle valute fiat in stablecoin in BinanceWrapper
* Refactor: WrapperHandler for managing API wrappers with retry logic; update related modules and tests
* Refactor: Update ProductInfo and Price classes to include aggregation methods; remove standalone aggregation functions
* fix docs
This commit was merged in pull request #24.
This commit is contained in:
Giacomo Bertolazzi
2025-10-11 21:36:13 +02:00
committed by GitHub
parent 517842c834
commit 093a7f5a48
40 changed files with 284 additions and 238 deletions

View File

@@ -1,5 +1,18 @@
import pytest
from app.markets.binance import BinanceWrapper
import asyncio
from app.api.markets.binance import BinanceWrapper
# fix warning about no event loop
@pytest.fixture(scope="session", autouse=True)
def event_loop():
"""
Ensure there is an event loop for the duration of the tests.
"""
loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)
yield loop
loop.close()
@pytest.mark.market
@pytest.mark.api
@@ -51,3 +64,18 @@ class TestBinance:
assert entry.close > 0
assert entry.high > 0
assert entry.timestamp != ''
def test_binance_fiat_conversion(self):
market = BinanceWrapper(currency="USD")
assert market.currency == "USDT"
product = market.get_product("BTC")
assert product is not None
assert product.symbol == "BTC"
assert product.price > 0
market = BinanceWrapper(currency="EUR")
assert market.currency == "EUR"
product = market.get_product("BTC")
assert product is not None
assert product.symbol == "BTC"
assert product.price > 0

View File

@@ -1,6 +1,6 @@
import os
import pytest
from app.markets import CoinBaseWrapper
from app.api.markets import CoinBaseWrapper
@pytest.mark.market
@pytest.mark.api

View File

@@ -1,6 +1,6 @@
import os
import pytest
from app.markets import CryptoCompareWrapper
from app.api.markets import CryptoCompareWrapper
@pytest.mark.market
@pytest.mark.api

View File

@@ -1,6 +1,6 @@
import os
import pytest
from app.news import CryptoPanicWrapper
from app.api.news import CryptoPanicWrapper
@pytest.mark.limited

View File

@@ -1,5 +1,5 @@
import pytest
from app.news import DuckDuckGoWrapper
from app.api.news import DuckDuckGoWrapper
@pytest.mark.news

View File

@@ -1,5 +1,5 @@
import pytest
from app.news import GoogleNewsWrapper
from app.api.news import GoogleNewsWrapper
@pytest.mark.news

View File

@@ -1,6 +1,6 @@
import os
import pytest
from app.news import NewsApiWrapper
from app.api.news import NewsApiWrapper
@pytest.mark.news

View File

@@ -1,6 +1,6 @@
import os
import pytest
from app.social.reddit import MAX_COMMENTS, RedditWrapper
from app.api.social.reddit import MAX_COMMENTS, RedditWrapper
@pytest.mark.social
@pytest.mark.api

View File

@@ -1,5 +1,5 @@
import pytest
from app.markets import YFinanceWrapper
from app.api.markets import YFinanceWrapper
@pytest.mark.market
@pytest.mark.api