Skip to content

Commit

Permalink
Update log text in tests as well.
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathangreen committed Jun 13, 2024
1 parent 5e21f1d commit a83fc20
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
5 changes: 3 additions & 2 deletions src/palace/manager/celery/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
12 changes: 9 additions & 3 deletions tests/manager/celery/tasks/test_patron_activity.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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.
Expand All @@ -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
)
Expand Down

0 comments on commit a83fc20

Please sign in to comment.