From a83fc2073b3671315da16fad12e0849d9512b1b0 Mon Sep 17 00:00:00 2001 From: Jonathan Green Date: Thu, 13 Jun 2024 14:18:44 -0300 Subject: [PATCH] Update log text in tests as well. --- src/palace/manager/celery/app.py | 5 +++-- tests/manager/celery/tasks/test_patron_activity.py | 12 +++++++++--- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/palace/manager/celery/app.py b/src/palace/manager/celery/app.py index ecf65a7eeb..19a70bd28f 100644 --- a/src/palace/manager/celery/app.py +++ b/src/palace/manager/celery/app.py @@ -39,11 +39,12 @@ def import_celery_tasks() -> None: @setup_logging.connect def celery_logger_setup(loglevel: int, logfile: str | None, **kwargs: Any) -> None: - container_level = services.logging.config.level().levelno # type: ignore[attr-defined] + level = services.logging.config.level() # type: ignore[attr-defined] + container_level = level.levelno if level else None root_logger = logging.getLogger() # If celery requested a lower log level, then we update the root logger to use the lower level. - if loglevel < container_level: + if container_level is None or loglevel < container_level: root_logger.setLevel(loglevel) # If celery requested a log file, then we update the root logger to also log to the file. diff --git a/tests/manager/celery/tasks/test_patron_activity.py b/tests/manager/celery/tasks/test_patron_activity.py index 54c73e7f30..00fbb60e38 100644 --- a/tests/manager/celery/tasks/test_patron_activity.py +++ b/tests/manager/celery/tasks/test_patron_activity.py @@ -80,7 +80,10 @@ def test_unable_to_lock( (sync_task_fixture.collection.id, sync_task_fixture.patron.id, "pin") ).wait() - assert "Patron activity sync not needed (state: LOCKED)" in caplog.text + assert ( + "Patron activity sync task could not acquire lock. " + "Task will not perform sync. Lock state (LOCKED)" + ) in caplog.text assert mock_session.call_count == 0 def test_patron_not_found( @@ -190,7 +193,10 @@ def test_force( (sync_task_fixture.collection.id, sync_task_fixture.patron.id, "pin") ).wait() - assert "Patron activity sync not needed (state: FAILED)" in caplog.text + assert ( + "Patron activity sync task could not acquire lock. " + "Task will not perform sync. Lock state (FAILED)" + ) in caplog.text sync_task_fixture.mock_registry.from_collection.assert_not_called() # But if we force it, we should run it again. @@ -199,7 +205,7 @@ def test_force( (sync_task_fixture.collection.id, sync_task_fixture.patron.id, "pin"), {"force": True}, ).wait() - assert "Patron activity sync not needed" not in caplog.text + assert "Patron activity sync task could not acquire lock" not in caplog.text sync_task_fixture.mock_registry.from_collection.assert_called_once_with( sync_task_fixture.db.session, sync_task_fixture.collection )