diff --git a/examples/example.py b/examples/example.py index 477204a7..53a2fe45 100644 --- a/examples/example.py +++ b/examples/example.py @@ -9,11 +9,12 @@ from fastapi import FastAPI from loguru import logger -from findmyorder import FindMyOrder, __version__ +from findmyorder import FindMyOrder logger.remove() logger.add(sys.stderr, level="INFO") + async def main(): """Main""" while True: diff --git a/findmyorder/__init__.py b/findmyorder/__init__.py index a6f317d3..9febe9e0 100644 --- a/findmyorder/__init__.py +++ b/findmyorder/__init__.py @@ -3,5 +3,8 @@ """ __version__ = "1.7.36" -from .config import settings from .main import FindMyOrder + +__all__ = [ + "FindMyOrder", +] diff --git a/tests/test_unit.py b/tests/test_unit.py index daec0507..900ceec7 100644 --- a/tests/test_unit.py +++ b/tests/test_unit.py @@ -6,29 +6,33 @@ import pytest -from findmyorder import FindMyOrder, settings +from findmyorder import FindMyOrder +from findmyorder.config import settings @pytest.fixture(scope="session", autouse=True) def set_test_settings(): settings.configure(FORCE_ENV_FOR_DYNACONF="testing") - + @pytest.fixture(name="fmo") def fmo(): """return fmo""" return FindMyOrder() + @pytest.fixture def order(): """return valid order""" return "buy EURUSD sl=200 tp=400 q=2%" + @pytest.fixture def short_order(): """return valid order""" return "Buy EURUSD" + @pytest.fixture def result_order(): """return standard expected results""" @@ -41,24 +45,28 @@ def result_order(): "order_type": None, "leverage_type": None, "comment": None, - "timestamp": datetime.now() + "timestamp": datetime.now(), } + @pytest.fixture def ignore_order(): """return valid order""" return "buy US500" + @pytest.fixture def crypto_order(): """return valid order""" return "SHORT ETH sl=200 tp=400 q=2%" + @pytest.fixture def crypto_short_order(): """return valid order""" return "Sell ETH" + @pytest.fixture def result_crypto_order(): """return standard expected results""" @@ -71,8 +79,9 @@ def result_crypto_order(): "order_type": None, "leverage_type": None, "comment": None, - "timestamp": datetime.now() - } + "timestamp": datetime.now(), + } + @pytest.fixture def order_with_emoji(): @@ -93,6 +102,7 @@ def invalid_order(): """return fmo""" return "This is not an order" + @pytest.mark.asyncio async def test_settings(): """Search Testing""" @@ -108,6 +118,7 @@ async def test_info(fmo): assert result is not None assert str(result).startswith("FindMyOrder") + @pytest.mark.asyncio async def test_search_valid_order(fmo, crypto_order): """Search Testing""" @@ -134,13 +145,13 @@ async def test_search_exception(fmo): @pytest.mark.asyncio -async def test_search_normal_order(fmo,order): +async def test_search_normal_order(fmo, order): """Search Testing""" assert await fmo.search(order) is True @pytest.mark.asyncio -async def test_search_normal_order_variation(fmo,crypto_order): +async def test_search_normal_order_variation(fmo, crypto_order): """Search Testing""" assert await fmo.search(crypto_order) is True @@ -159,7 +170,6 @@ async def test_identify_order_invalid_input(fmo, invalid_order): assert str(result).startswith("Expected") - @pytest.mark.asyncio async def test_valid_get_order(fmo, order, result_order): """get order Testing""" @@ -200,16 +210,10 @@ async def test_invalid_get_order(fmo, invalid_order): @pytest.mark.asyncio -async def test_mapping_order( - fmo, - crypto_short_order, - result_crypto_order): +async def test_mapping_order(fmo, crypto_short_order, result_crypto_order): """replace instrument Testing""" result = await fmo.get_order(crypto_short_order) print(result) assert settings.instrument_mapping is True assert result["instrument"] == result_crypto_order["instrument"] assert type(result["timestamp"] is datetime) - - -