Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🚨 Linter cleanup #302

Merged
merged 3 commits into from
Sep 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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",
]
34 changes: 19 additions & 15 deletions tests/test_unit.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"""
Expand All @@ -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"""
Expand All @@ -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():
Expand All @@ -93,6 +102,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 +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"""
Expand All @@ -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

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