Skip to content

Commit

Permalink
✅ Unit Test
Browse files Browse the repository at this point in the history
  • Loading branch information
mraniki committed Jul 7, 2024
1 parent b7e1075 commit 694bdde
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 11 deletions.
2 changes: 1 addition & 1 deletion findmyorder/handler/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def __init__(self, **kwargs):
self.name = kwargs.get("name", None)
self.client = None
self.enabled = kwargs.get("enabled", None)
self.action_identifier = kwargs.get("action_identifier", None)
self.action_identifier = kwargs.get("action_identifier", "BUY SELL")
self.action_identifier = self.action_identifier.lower()
self.stop_loss_identifier = kwargs.get("stop_loss_identifier", None)
self.take_profit_identifier = kwargs.get("take_profit_identifier", None)
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ addopts = """
-v
--show-capture=stderr
"""
asyncio_mode = "auto"

[tool.coverage.run]
omit = [
Expand Down
20 changes: 11 additions & 9 deletions tests/test_unit.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ async def test_invalid_get_order(fmo, invalid_order):
assert result is None


@pytest.mark.asyncio
async def test_standard_get_order(fmo, order, result_order):
"""get order Testing"""
result = await fmo.get_order(order)
Expand All @@ -156,12 +157,13 @@ async def test_standard_get_order(fmo, order, result_order):
assert type(result["timestamp"] is datetime)


async def test_create_client_exception(fmo, caplog):
result = fmo.create_client()
assert result is not None
assert any(
record.message
== "No Client were created. Check your settings or disable the module."
for record in caplog.records
if record.levelname == "WARNING"
)
# @pytest.mark.asyncio
# async def test_create_client_exception(fmo, caplog):
# result = fmo.create_client()
# assert result is not None
# assert any(
# record.message
# == "No Client were created. Check your settings or disable the module."
# for record in caplog.records
# if record.levelname == "WARNING"
# )
4 changes: 3 additions & 1 deletion tests/test_unit_exception.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ def fmo():
return FindMyOrder()


@pytest.mark.asyncio
async def test_module_exception(fmo, caplog):
result = FindMyOrder()
print(result)
Expand All @@ -29,10 +30,11 @@ async def test_module_exception(fmo, caplog):
)


# @pytest.mark.asyncio
async def test_create_client_exception(caplog):
settings.findmyorder_enabled = True
fmo = FindMyOrder()
result = fmo.create_client()
result = fmo._create_client()
print(result)
assert result is not None
assert any(
Expand Down

0 comments on commit 694bdde

Please sign in to comment.