Skip to content

test: replace logger patch with caplog in version and rag pipeline tests#37554

Merged
asukaminato0721 merged 1 commit into
langgenius:mainfrom
jithu2111:chore/test-logger-caplog
Jun 17, 2026
Merged

test: replace logger patch with caplog in version and rag pipeline tests#37554
asukaminato0721 merged 1 commit into
langgenius:mainfrom
jithu2111:chore/test-logger-caplog

Conversation

@jithu2111

Copy link
Copy Markdown
Contributor

Summary

Part of #37468. Replaces @patch(...logger...) / patch.object(logger, ...) mocking with pytest's caplog fixture in two unit test files:

  • tests/unit_tests/controllers/console/test_version.py
  • tests/unit_tests/services/test_rag_pipeline_task_proxy.py

caplog captures the actual log output instead of asserting that a mocked logger method was called, which is less brittle (independent of logger names / import paths) and reduces boilerplate. This follows the existing pattern in tests/unit_tests/libs/test_workspace_permission.py.

Using Refs rather than Fixes because #37468 spans ~8 files and is being open for the remaining files.

Happy to follow up with the remaining files in separate PRs if this approach looks good.

Checklist

  • I understand that this PR may be closed in case there was no previous discussion or issues.
  • I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change.
  • This change requires a documentation update
  • I've updated the documentation accordingly.

Refs #37468

@dosubot dosubot Bot added the size:XS This PR changes 0-9 lines, ignoring generated files. label Jun 16, 2026
@dosubot dosubot Bot added the lgtm This PR has been approved by a maintainer label Jun 17, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Pyrefly Diff

base → PR
--- /tmp/pyrefly_base.txt	2026-06-17 01:38:12.491304738 +0000
+++ /tmp/pyrefly_pr.txt	2026-06-17 01:37:58.734285297 +0000
@@ -1865,31 +1865,31 @@
 ERROR No attribute `MethodView` in module `builtins` [missing-attribute]
  --> tests/unit_tests/controllers/common/test_fields.py:9:5
 ERROR Argument `SimpleNamespace` is not assignable to parameter `current_user` with type `Account` in function `controllers.console.app.completion._create_chat_message` [bad-argument-type]
-   --> tests/unit_tests/controllers/console/agent/test_agent_controllers.py:583:74
+   --> tests/unit_tests/controllers/console/agent/test_agent_controllers.py:575:74
 ERROR Argument `SimpleNamespace` is not assignable to parameter `app_model` with type `App` in function `controllers.console.app.completion._create_chat_message` [bad-argument-type]
-   --> tests/unit_tests/controllers/console/agent/test_agent_controllers.py:583:98
+   --> tests/unit_tests/controllers/console/agent/test_agent_controllers.py:575:98
 ERROR Argument `SimpleNamespace` is not assignable to parameter `current_user` with type `Account` in function `controllers.console.app.completion._create_chat_message` [bad-argument-type]
-   --> tests/unit_tests/controllers/console/agent/test_agent_controllers.py:633:30
+   --> tests/unit_tests/controllers/console/agent/test_agent_controllers.py:625:30
 ERROR Argument `SimpleNamespace` is not assignable to parameter `app_model` with type `App` in function `controllers.console.app.completion._create_chat_message` [bad-argument-type]
-   --> tests/unit_tests/controllers/console/agent/test_agent_controllers.py:634:27
+   --> tests/unit_tests/controllers/console/agent/test_agent_controllers.py:626:27
 ERROR Object of class `object` has no attribute `data` [missing-attribute]
-   --> tests/unit_tests/controllers/console/agent/test_agent_controllers.py:714:50
+   --> tests/unit_tests/controllers/console/agent/test_agent_controllers.py:706:50
 ERROR Object of class `object` has no attribute `limit` [missing-attribute]
-   --> tests/unit_tests/controllers/console/agent/test_agent_controllers.py:715:30
+   --> tests/unit_tests/controllers/console/agent/test_agent_controllers.py:707:30
 ERROR Object of class `object` has no attribute `has_more` [missing-attribute]
-   --> tests/unit_tests/controllers/console/agent/test_agent_controllers.py:716:33
+   --> tests/unit_tests/controllers/console/agent/test_agent_controllers.py:708:33
 ERROR Argument `SimpleNamespace` is not assignable to parameter `app_model` with type `App` in function `controllers.console.app.message._list_chat_messages` [bad-argument-type]
-   --> tests/unit_tests/controllers/console/agent/test_agent_controllers.py:728:67
+   --> tests/unit_tests/controllers/console/agent/test_agent_controllers.py:720:67
 ERROR Argument `SimpleNamespace` is not assignable to parameter `current_user` with type `Account` in function `controllers.console.app.message._update_message_feedback` [bad-argument-type]
-   --> tests/unit_tests/controllers/console/agent/test_agent_controllers.py:744:30
+   --> tests/unit_tests/controllers/console/agent/test_agent_controllers.py:736:30
 ERROR Argument `SimpleNamespace` is not assignable to parameter `app_model` with type `App` in function `controllers.console.app.message._update_message_feedback` [bad-argument-type]
-   --> tests/unit_tests/controllers/console/agent/test_agent_controllers.py:745:27
+   --> tests/unit_tests/controllers/console/agent/test_agent_controllers.py:737:27
 ERROR Argument `SimpleNamespace` is not assignable to parameter `current_user` with type `Account` in function `controllers.console.app.message._get_message_suggested_questions` [bad-argument-type]
-   --> tests/unit_tests/controllers/console/agent/test_agent_controllers.py:781:26
+   --> tests/unit_tests/controllers/console/agent/test_agent_controllers.py:773:26
 ERROR Argument `SimpleNamespace` is not assignable to parameter `app_model` with type `App` in function `controllers.console.app.message._get_message_suggested_questions` [bad-argument-type]
-   --> tests/unit_tests/controllers/console/agent/test_agent_controllers.py:782:23
+   --> tests/unit_tests/controllers/console/agent/test_agent_controllers.py:774:23
 ERROR Argument `Literal['00000000-0000-0000-0000-000000000002']` is not assignable to parameter `message_id` with type `UUID` in function `controllers.console.app.message._get_message_suggested_questions` [bad-argument-type]
-   --> tests/unit_tests/controllers/console/agent/test_agent_controllers.py:783:24
+   --> tests/unit_tests/controllers/console/agent/test_agent_controllers.py:775:24
 ERROR Object of class `int` has no attribute `lower` [missing-attribute]
    --> tests/unit_tests/controllers/console/app/test_annotation_security.py:221:38
 ERROR Object of class `int` has no attribute `lower` [missing-attribute]
@@ -6067,33 +6067,33 @@
 ERROR Argument `list[SimpleNamespace]` is not assignable to parameter `recipients` with type `Sequence[HumanInputFormRecipient]` in function `repositories.sqlalchemy_api_workflow_run_repository._build_human_input_required_reason` [bad-argument-type]
   --> tests/unit_tests/repositories/test_sqlalchemy_api_workflow_run_repository.py:56:9
 ERROR Argument `FakeSession` is not assignable to parameter `session` with type `Session` in function `services.agent.workflow_publish_service.WorkflowAgentPublishService.project_draft_bindings_to_graph` [bad-argument-type]
-    --> tests/unit_tests/services/agent/test_agent_services.py:1331:21
+    --> tests/unit_tests/services/agent/test_agent_services.py:1273:21
 ERROR Argument `FakeSession` is not assignable to parameter `session` with type `Session` in function `services.agent.workflow_publish_service.WorkflowAgentPublishService.sync_roster_agent_bindings_for_draft` [bad-argument-type]
-    --> tests/unit_tests/services/agent/test_agent_services.py:1390:21
+    --> tests/unit_tests/services/agent/test_agent_services.py:1329:21
 ERROR Argument `FakeSession` is not assignable to parameter `session` with type `Session` in function `services.agent.workflow_publish_service.WorkflowAgentPublishService.sync_agent_bindings_for_draft` [bad-argument-type]
-    --> tests/unit_tests/services/agent/test_agent_services.py:1459:21
+    --> tests/unit_tests/services/agent/test_agent_services.py:1398:21
 ERROR Argument `FakeSession` is not assignable to parameter `session` with type `Session` in function `services.agent.workflow_publish_service.WorkflowAgentPublishService.sync_agent_bindings_for_draft` [bad-argument-type]
-    --> tests/unit_tests/services/agent/test_agent_services.py:1514:25
+    --> tests/unit_tests/services/agent/test_agent_services.py:1453:25
 ERROR Argument `FakeSession` is not assignable to parameter `session` with type `Session` in function `services.agent.workflow_publish_service.WorkflowAgentPublishService.sync_agent_bindings_for_draft` [bad-argument-type]
-    --> tests/unit_tests/services/agent/test_agent_services.py:1546:25
+    --> tests/unit_tests/services/agent/test_agent_services.py:1485:25
 ERROR Argument `FakeSession` is not assignable to parameter `session` with type `Session` in function `services.agent.workflow_publish_service.WorkflowAgentPublishService.sync_agent_bindings_for_draft` [bad-argument-type]
-    --> tests/unit_tests/services/agent/test_agent_services.py:1578:25
+    --> tests/unit_tests/services/agent/test_agent_services.py:1517:25
 ERROR Argument `FakeSession` is not assignable to parameter `session` with type `Session` in function `services.agent.workflow_publish_service.WorkflowAgentPublishService.sync_agent_bindings_for_draft` [bad-argument-type]
-    --> tests/unit_tests/services/agent/test_agent_services.py:1624:25
+    --> tests/unit_tests/services/agent/test_agent_services.py:1563:25
 ERROR Argument `FakeSession` is not assignable to parameter `session` with type `Session` in function `services.agent.workflow_publish_service.WorkflowAgentPublishService.sync_roster_agent_bindings_for_draft` [bad-argument-type]
-    --> tests/unit_tests/services/agent/test_agent_services.py:1684:21
+    --> tests/unit_tests/services/agent/test_agent_services.py:1623:21
 ERROR Argument `FakeSession` is not assignable to parameter `session` with type `Session` in function `services.agent.workflow_publish_service.WorkflowAgentPublishService.sync_roster_agent_bindings_for_draft` [bad-argument-type]
-    --> tests/unit_tests/services/agent/test_agent_services.py:1754:21
+    --> tests/unit_tests/services/agent/test_agent_services.py:1693:21
 ERROR Argument `FakeSession` is not assignable to parameter `session` with type `Session` in function `services.agent.workflow_publish_service.WorkflowAgentPublishService.sync_roster_agent_bindings_for_draft` [bad-argument-type]
-    --> tests/unit_tests/services/agent/test_agent_services.py:1787:21
+    --> tests/unit_tests/services/agent/test_agent_services.py:1726:21
 ERROR Object of class `object` has no attribute `skills_files` [missing-attribute]
-    --> tests/unit_tests/services/agent/test_agent_services.py:1999:37
+    --> tests/unit_tests/services/agent/test_agent_services.py:1938:37
 ERROR Object of class `object` has no attribute `skills_files` [missing-attribute]
-    --> tests/unit_tests/services/agent/test_agent_services.py:2036:34
+    --> tests/unit_tests/services/agent/test_agent_services.py:1975:34
 ERROR Object of class `object` has no attribute `skills_files` [missing-attribute]
-    --> tests/unit_tests/services/agent/test_agent_services.py:2060:34
+    --> tests/unit_tests/services/agent/test_agent_services.py:1999:34
 ERROR Object of class `object` has no attribute `skills_files` [missing-attribute]
-    --> tests/unit_tests/services/agent/test_agent_services.py:2061:12
+    --> tests/unit_tests/services/agent/test_agent_services.py:2000:12
 ERROR Object of class `NoneType` has no attribute `workflow_prompt` [missing-attribute]
    --> tests/unit_tests/services/agent/test_composer_mention_validation.py:113:5
 ERROR Class member `ConcreteApiKeyAuth.validate_credentials` overrides a member in a parent class but is missing an `@override` decorator [missing-override-decorator]
@@ -6498,9 +6498,9 @@
 ERROR Argument `dict[str, Any]` is not assignable to parameter `utm_info` with type `UtmInfo` in function `services.operation_service.OperationService.record_utm` [bad-argument-type]
    --> tests/unit_tests/services/test_operation_service.py:117:57
 ERROR Argument `Literal['']` is not assignable to parameter `plan` with type `CloudPlan` in function `RagPipelineTaskProxyTestDataFactory.create_mock_features` [bad-argument-type]
-   --> tests/unit_tests/services/test_rag_pipeline_task_proxy.py:409:109
+   --> tests/unit_tests/services/test_rag_pipeline_task_proxy.py:410:109
 ERROR Argument `None` is not assignable to parameter `plan` with type `CloudPlan` in function `RagPipelineTaskProxyTestDataFactory.create_mock_features` [bad-argument-type]
-   --> tests/unit_tests/services/test_rag_pipeline_task_proxy.py:431:109
+   --> tests/unit_tests/services/test_rag_pipeline_task_proxy.py:432:109
 ERROR Argument `dict[str, Any]` is not assignable to parameter `node_config` with type `NodeConfigDict` in function `services.trigger.schedule_service.ScheduleService.to_schedule_config` [bad-argument-type]
    --> tests/unit_tests/services/test_schedule_service.py:521:61
 ERROR Argument `dict[str, str | dict[str, str]]` is not assignable to parameter `node_config` with type `NodeConfigDict` in function `services.trigger.schedule_service.ScheduleService.to_schedule_config` [bad-argument-type]

@github-actions

Copy link
Copy Markdown
Contributor

Pyrefly Type Coverage

Metric Base PR Delta
Type coverage 48.60% 48.59% -0.01%
Strict coverage 48.11% 48.10% -0.01%
Typed symbols 28,005 27,995 -10
Untyped symbols 29,924 29,923 -1
Modules 2892 2892 0

@asukaminato0721 asukaminato0721 added this pull request to the merge queue Jun 17, 2026
Merged via the queue into langgenius:main with commit 3f81ec1 Jun 17, 2026
31 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm This PR has been approved by a maintainer size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants