Skip to content

Commit

Permalink
fix test code
Browse files Browse the repository at this point in the history
  • Loading branch information
pileks committed Sep 22, 2023
1 parent 30f07a5 commit af153d8
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
6 changes: 3 additions & 3 deletions packages/plugins/polywrap-logger-plugin/tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import logging
import pytest
from polywrap_logger_plugin import LoggerConfig, LoggerLogLevel
from polywrap_logger_plugin import LoggerConfig, LogLevel
from typing import Callable


@pytest.fixture
def valid_logger_config() -> Callable[[LoggerLogLevel], LoggerConfig]:
def _valid_logger_config(level: LoggerLogLevel) -> LoggerConfig:
def valid_logger_config() -> Callable[[LogLevel], LoggerConfig]:
def _valid_logger_config(level: LogLevel) -> LoggerConfig:
return LoggerConfig(logger=logging.getLogger("test_logger"), level=level)
return _valid_logger_config

Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
from polywrap_client import PolywrapClient
from polywrap_core import Uri
import pytest
from polywrap_logger_plugin import LoggerLogLevel
from polywrap_logger_plugin import LogLevel
from _pytest.logging import LogCaptureFixture


@pytest.mark.parametrize("log_level", [0, 1, 2 ,3])
async def test_log_levels(
client: PolywrapClient,
caplog: LogCaptureFixture,
log_level: LoggerLogLevel,
log_level: LogLevel,
):
caplog.set_level(logging.DEBUG)
args_log = dict(message="Test message", level=log_level)
Expand All @@ -22,7 +22,7 @@ async def test_log_levels(
)
last_record = caplog.records[-1] if caplog.records else None

if log_level >= LoggerLogLevel.INFO:
if log_level >= LogLevel.INFO:
assert last_record
assert last_record.levelno == (log_level + 1) * 10
assert last_record.message == "Test message"
Expand Down
12 changes: 6 additions & 6 deletions packages/plugins/polywrap-logger-plugin/tests/unit/test_log.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import logging
from polywrap_core import InvokerClient
import pytest
from polywrap_logger_plugin import LoggerConfig, LoggerModule, ArgsLog, LoggerLogLevel
from polywrap_logger_plugin import LoggerConfig, LoggerModule, ArgsLog, LogLevel
from _pytest.logging import LogCaptureFixture
from typing import Callable, cast


@pytest.mark.parametrize("config_level", list(LoggerLogLevel))
@pytest.mark.parametrize("log_level", list(LoggerLogLevel))
@pytest.mark.parametrize("config_level", list(LogLevel))
@pytest.mark.parametrize("log_level", list(LogLevel))
async def test_log_levels(
caplog: LogCaptureFixture,
valid_logger_config: Callable[[LoggerLogLevel], LoggerConfig],
config_level: LoggerLogLevel,
log_level: LoggerLogLevel,
valid_logger_config: Callable[[LogLevel], LoggerConfig],
config_level: LogLevel,
log_level: LogLevel,
):
caplog.set_level(logging.DEBUG)
logger_module = LoggerModule(valid_logger_config(config_level))
Expand Down

0 comments on commit af153d8

Please sign in to comment.