Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

test(e2e): bring three container service tests under strict pyrefly (#45329)

Felix Shiff12c7d74f35
diff --git a/api/tests/e2e_tests/containers/pyrefly.toml b/api/tests/e2e_tests/containers/pyrefly.toml
index cd53ebc1b98..e44fc965069 100644
--- a/api/tests/e2e_tests/containers/pyrefly.toml
+++ b/api/tests/e2e_tests/containers/pyrefly.toml
@@ -48,13 +48,11 @@ project-excludes = [
"services/test_attachment_service.py",
"services/test_audio_service_db.py",
"services/test_conversation_service.py",
- "services/test_conversation_variable_updater.py",
"services/test_dataset_permission_service.py",
"services/test_dataset_service.py",
"services/test_dataset_service_batch_update_document_status.py",
"services/test_dataset_service_create_dataset.py",
"services/test_dataset_service_document.py",
- "services/test_dataset_service_get_segments.py",
"services/test_dataset_service_permissions.py",
"services/test_dataset_service_retrieval.py",
"services/test_delete_archived_workflow_run.py",
@@ -69,7 +67,6 @@ project-excludes = [
"services/test_messages_clean_service.py",
"services/test_model_load_balancing_service.py",
"services/test_model_provider_service.py",
- "services/test_restore_archived_workflow_run.py",
"services/test_schedule_service.py",
"services/test_webapp_auth_service.py",
"services/test_webhook_service.py",
diff --git a/api/tests/e2e_tests/containers/services/test_conversation_variable_updater.py b/api/tests/e2e_tests/containers/services/test_conversation_variable_updater.py
index 638a962f18b..6e4cd0d8c4c 100644
--- a/api/tests/e2e_tests/containers/services/test_conversation_variable_updater.py
+++ b/api/tests/e2e_tests/containers/services/test_conversation_variable_updater.py
@@ -30,7 +30,7 @@ class TestConversationVariableUpdater:
db_session_with_containers.commit()
return row
- def test_should_update_conversation_variable_data_and_commit(self, db_session_with_containers: Session):
+ def test_should_update_conversation_variable_data_and_commit(self, db_session_with_containers: Session) -> None:
conversation_id = str(uuid4())
variable = StringVariable(id=str(uuid4()), name="topic", value="old value")
self._create_conversation_variable(
@@ -47,7 +47,7 @@ class TestConversationVariableUpdater:
assert row is not None
assert row.data == updated_variable.model_dump_json()
- def test_should_raise_not_found_when_variable_missing(self, db_session_with_containers: Session):
+ def test_should_raise_not_found_when_variable_missing(self, db_session_with_containers: Session) -> None:
conversation_id = str(uuid4())
variable = StringVariable(id=str(uuid4()), name="topic", value="value")
updater = ConversationVariableUpdater(sessionmaker(bind=db.engine))
@@ -55,7 +55,7 @@ class TestConversationVariableUpdater:
with pytest.raises(ConversationVariableNotFoundError, match="conversation variable not found in the database"):
updater.update(conversation_id=conversation_id, variable=variable)
- def test_should_do_nothing_when_flush_is_called(self, db_session_with_containers: Session):
+ def test_should_do_nothing_when_flush_is_called(self, db_session_with_containers: Session) -> None:
updater = ConversationVariableUpdater(sessionmaker(bind=db.engine))
result = updater.flush()
diff --git a/api/tests/e2e_tests/containers/services/test_dataset_service_get_segments.py b/api/tests/e2e_tests/containers/services/test_dataset_service_get_segments.py
index c4546648314..8f33f14a33e 100644
--- a/api/tests/e2e_tests/containers/services/test_dataset_service_get_segments.py
+++ b/api/tests/e2e_tests/containers/services/test_dataset_service_get_segments.py
@@ -137,7 +137,7 @@ class TestSegmentServiceGetSegments:
- Combined filters
"""
- def test_get_segments_basic_pagination(self, db_session_with_containers: Session):
+ def test_get_segments_basic_pagination(self, db_session_with_containers: Session) -> None:
"""
Test basic pagination functionality.
@@ -183,7 +183,7 @@ class TestSegmentServiceGetSegments:
assert items[0].id == segment1.id
assert items[1].id == segment2.id
- def test_get_segments_with_status_filter(self, db_session_with_containers: Session):
+ def test_get_segments_with_status_filter(self, db_session_with_containers: Session) -> None:
"""
Test filtering by status list.
@@ -240,7 +240,7 @@ class TestSegmentServiceGetSegments:
statuses = {item.status for item in items}
assert statuses == {"completed", "indexing"}
- def test_get_segments_with_empty_status_list(self, db_session_with_containers: Session):
+ def test_get_segments_with_empty_status_list(self, db_session_with_containers: Session) -> None:
"""
Test with empty status list.
@@ -283,7 +283,7 @@ class TestSegmentServiceGetSegments:
assert len(items) == 2
assert total == 2
- def test_get_segments_with_keyword_search(self, db_session_with_containers: Session):
+ def test_get_segments_with_keyword_search(self, db_session_with_containers: Session) -> None:
"""
Test keyword search functionality.
@@ -327,7 +327,7 @@ class TestSegmentServiceGetSegments:
assert total == 1
assert "search term" in items[0].content
- def test_get_segments_ordering_by_position_and_id(self, db_session_with_containers: Session):
+ def test_get_segments_ordering_by_position_and_id(self, db_session_with_containers: Session) -> None:
"""
Test ordering by position and id.
@@ -384,7 +384,7 @@ class TestSegmentServiceGetSegments:
assert items[1].id == seg_pos2.id
assert items[2].id == seg_pos3.id
- def test_get_segments_empty_results(self, db_session_with_containers: Session):
+ def test_get_segments_empty_results(self, db_session_with_containers: Session) -> None:
"""
Test when no segments match the criteria.
@@ -405,7 +405,7 @@ class TestSegmentServiceGetSegments:
assert items == []
assert total == 0
- def test_get_segments_combined_filters(self, db_session_with_containers: Session):
+ def test_get_segments_combined_filters(self, db_session_with_containers: Session) -> None:
"""
Test with multiple filters combined.
@@ -469,7 +469,7 @@ class TestSegmentServiceGetSegments:
assert items[0].status == "completed"
assert "important" in items[0].content
- def test_get_segments_with_none_status_list(self, db_session_with_containers: Session):
+ def test_get_segments_with_none_status_list(self, db_session_with_containers: Session) -> None:
"""
Test with None status list.
@@ -515,7 +515,7 @@ class TestSegmentServiceGetSegments:
assert len(items) == 2
assert total == 2
- def test_get_segments_pagination_max_per_page_limit(self, db_session_with_containers: Session):
+ def test_get_segments_pagination_max_per_page_limit(self, db_session_with_containers: Session) -> None:
"""
Test that max_per_page is correctly set to 100.
diff --git a/api/tests/e2e_tests/containers/services/test_restore_archived_workflow_run.py b/api/tests/e2e_tests/containers/services/test_restore_archived_workflow_run.py
index 2f209496110..c6a46141396 100644
--- a/api/tests/e2e_tests/containers/services/test_restore_archived_workflow_run.py
+++ b/api/tests/e2e_tests/containers/services/test_restore_archived_workflow_run.py
@@ -17,13 +17,13 @@ from services.retention.workflow_run.restore_archived_workflow_run import Workfl
class TestWorkflowRunRestore:
"""Tests for the WorkflowRunRestore class."""
- def test_restore_initialization(self):
+ def test_restore_initialization(self) -> None:
"""Restore service should respect dry_run flag."""
restore = WorkflowRunRestore(dry_run=True)
assert restore.dry_run is True
- def test_convert_datetime_fields(self):
+ def test_convert_datetime_fields(self) -> None:
"""ISO datetime strings should be converted to datetime objects."""
record = {
"id": "test-id",
@@ -40,7 +40,7 @@ class TestWorkflowRunRestore:
assert result["created_at"].month == 1
assert result["name"] == "test"
- def test_restore_table_records_returns_rowcount(self, db_session_with_containers: Session):
+ def test_restore_table_records_returns_rowcount(self, db_session_with_containers: Session) -> None:
"""Restore should return inserted rowcount."""
restore = WorkflowRunRestore()
record_id = str(uuid4())
@@ -66,7 +66,7 @@ class TestWorkflowRunRestore:
restored_pause = db_session_with_containers.scalar(select(WorkflowPause).where(WorkflowPause.id == record_id))
assert restored_pause is not None
- def test_restore_table_records_unknown_table(self, db_session_with_containers: Session):
+ def test_restore_table_records_unknown_table(self, db_session_with_containers: Session) -> None:
"""Unknown table names should be ignored gracefully."""
restore = WorkflowRunRestore()