From 11b29763f1c70397d896ef52bbee6475752c1882 Mon Sep 17 00:00:00 2001 From: mraniki <8766259+mraniki@users.noreply.github.com> Date: Wed, 27 Sep 2023 19:37:12 +0200 Subject: [PATCH 1/3] =?UTF-8?q?=F0=9F=9A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/example.py | 3 ++- findmyorder/__init__.py | 5 ++++- findmyorder/main.py | 3 +-- tests/test_unit.py | 31 +++++++++++++++++-------------- 4 files changed, 24 insertions(+), 18 deletions(-) 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/findmyorder/main.py b/findmyorder/main.py index e7046317..d2dcd4ce 100644 --- a/findmyorder/main.py +++ b/findmyorder/main.py @@ -17,8 +17,7 @@ ) from findmyorder import __version__ - -from .config import settings +from findmyorder.config import settings class FindMyOrder: diff --git a/tests/test_unit.py b/tests/test_unit.py index daec0507..0cdd59ba 100644 --- a/tests/test_unit.py +++ b/tests/test_unit.py @@ -12,23 +12,26 @@ @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 +44,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 +78,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 +101,7 @@ def invalid_order(): """return fmo""" return "This is not an order" + @pytest.mark.asyncio async def test_settings(): """Search Testing""" @@ -108,6 +117,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 +144,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 +169,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 +209,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) - - - From 0f096aa801af1f921df4b9def857a818abce0538 Mon Sep 17 00:00:00 2001 From: mraniki <8766259+mraniki@users.noreply.github.com> Date: Wed, 27 Sep 2023 19:56:31 +0200 Subject: [PATCH 2/3] =?UTF-8?q?=F0=9F=9A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- findmyorder/main.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/findmyorder/main.py b/findmyorder/main.py index d2dcd4ce..e7046317 100644 --- a/findmyorder/main.py +++ b/findmyorder/main.py @@ -17,7 +17,8 @@ ) from findmyorder import __version__ -from findmyorder.config import settings + +from .config import settings class FindMyOrder: From a5144ba02114547693162b3c970de16f61ec3237 Mon Sep 17 00:00:00 2001 From: mraniki <8766259+mraniki@users.noreply.github.com> Date: Wed, 27 Sep 2023 20:08:57 +0200 Subject: [PATCH 3/3] =?UTF-8?q?=F0=9F=9A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/test_unit.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/test_unit.py b/tests/test_unit.py index 0cdd59ba..900ceec7 100644 --- a/tests/test_unit.py +++ b/tests/test_unit.py @@ -6,7 +6,8 @@ import pytest -from findmyorder import FindMyOrder, settings +from findmyorder import FindMyOrder +from findmyorder.config import settings @pytest.fixture(scope="session", autouse=True)