Skip to content

Commit

Permalink
✅ Unit Test
Browse files Browse the repository at this point in the history
  • Loading branch information
mraniki committed Jul 6, 2024
1 parent 2a13706 commit 99f992b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 19 deletions.
11 changes: 7 additions & 4 deletions findmyorder/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,14 @@ def __init__(
self.clients = []
# Create a client for each client in settings
for name, client_config in settings.findmyorder.items():
# logger.debug("client_config: {}", client_config)
# Skip template and empty string client names
if (
# Skip empty client configs
client_config is None
# Skip non-dict client configs
or not isinstance(client_config, dict)
# Skip template and empty string client names
or name in ["", "template"]
# Skip disabled clients
or not client_config.get("enabled")
):
continue
Expand All @@ -71,10 +74,10 @@ def __init__(
logger.error(f"Failed to create parser {name}: {e}")

# Log the number of clients that were created
logger.info(f"Loaded {len(self.clients)} parsers")
logger.info(f"Loaded {len(self.clients)} clients")
if not self.clients:
logger.warning(
"No Parsers were created. Check your settings or disable the module."
"No Client were created. Check your settings or disable the module."
)

def _create_client(self, **kwargs):
Expand Down
30 changes: 15 additions & 15 deletions tests/test_exception.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,25 @@
FindMyOrder Exception Testing
"""

# import pytest
import pytest

# from findmyorder import FindMyOrder
# from findmyorder.config import 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="exception")
@pytest.fixture(scope="session", autouse=True)
def set_test_settings():
settings.configure(FORCE_ENV_FOR_DYNACONF="exception")


# @pytest.fixture(name="fmo")
# def fmo():
# """return fmo"""
# return FindMyOrder()
@pytest.fixture(name="fmo")
def fmo():
"""return fmo"""
return FindMyOrder()


# @pytest.mark.asyncio
# async def test_exception(fmo):
# """Search Testing"""
# for client in fmo.clients:
# assert client is None
@pytest.mark.asyncio
async def test_exception(fmo):
"""Search Testing"""
for client in fmo.clients:
assert client is None

0 comments on commit 99f992b

Please sign in to comment.