Skip to content

Commit

Permalink
🚨
Browse files Browse the repository at this point in the history
  • Loading branch information
mraniki committed Sep 27, 2023
1 parent a4533e5 commit 11b2976
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 18 deletions.
3 changes: 2 additions & 1 deletion examples/example.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
5 changes: 4 additions & 1 deletion findmyorder/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,8 @@
"""
__version__ = "1.7.36"

from .config import settings
from .main import FindMyOrder

__all__ = [
"FindMyOrder",
]
3 changes: 1 addition & 2 deletions findmyorder/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@
)

from findmyorder import __version__

from .config import settings
from findmyorder.config import settings


class FindMyOrder:
Expand Down
31 changes: 17 additions & 14 deletions tests/test_unit.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"""
Expand All @@ -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"""
Expand All @@ -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():
Expand All @@ -93,6 +101,7 @@ def invalid_order():
"""return fmo"""
return "This is not an order"


@pytest.mark.asyncio
async def test_settings():
"""Search Testing"""
Expand All @@ -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"""
Expand All @@ -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

Expand All @@ -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"""
Expand Down Expand Up @@ -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)



0 comments on commit 11b2976

Please sign in to comment.