mirror of
https://github.com/langgenius/dify.git
synced 2025-12-25 01:00:42 -05:00
ruff check preview (#25653)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
This commit is contained in:
@@ -12,6 +12,7 @@ and realistic testing scenarios with actual PostgreSQL and Redis instances.
|
||||
|
||||
import uuid
|
||||
from datetime import datetime
|
||||
from pathlib import Path
|
||||
from unittest.mock import MagicMock, patch
|
||||
|
||||
import pytest
|
||||
@@ -276,8 +277,7 @@ class TestBatchCreateSegmentToIndexTask:
|
||||
mock_storage = mock_external_service_dependencies["storage"]
|
||||
|
||||
def mock_download(key, file_path):
|
||||
with open(file_path, "w", encoding="utf-8") as f:
|
||||
f.write(csv_content)
|
||||
Path(file_path).write_text(csv_content, encoding="utf-8")
|
||||
|
||||
mock_storage.download.side_effect = mock_download
|
||||
|
||||
@@ -505,7 +505,7 @@ class TestBatchCreateSegmentToIndexTask:
|
||||
db.session.commit()
|
||||
|
||||
# Test each unavailable document
|
||||
for i, document in enumerate(test_cases):
|
||||
for document in test_cases:
|
||||
job_id = str(uuid.uuid4())
|
||||
batch_create_segment_to_index_task(
|
||||
job_id=job_id,
|
||||
@@ -601,8 +601,7 @@ class TestBatchCreateSegmentToIndexTask:
|
||||
mock_storage = mock_external_service_dependencies["storage"]
|
||||
|
||||
def mock_download(key, file_path):
|
||||
with open(file_path, "w", encoding="utf-8") as f:
|
||||
f.write(empty_csv_content)
|
||||
Path(file_path).write_text(empty_csv_content, encoding="utf-8")
|
||||
|
||||
mock_storage.download.side_effect = mock_download
|
||||
|
||||
@@ -684,8 +683,7 @@ class TestBatchCreateSegmentToIndexTask:
|
||||
mock_storage = mock_external_service_dependencies["storage"]
|
||||
|
||||
def mock_download(key, file_path):
|
||||
with open(file_path, "w", encoding="utf-8") as f:
|
||||
f.write(csv_content)
|
||||
Path(file_path).write_text(csv_content, encoding="utf-8")
|
||||
|
||||
mock_storage.download.side_effect = mock_download
|
||||
|
||||
|
||||
@@ -362,7 +362,7 @@ class TestCleanDatasetTask:
|
||||
|
||||
# Create segments for each document
|
||||
segments = []
|
||||
for i, document in enumerate(documents):
|
||||
for document in documents:
|
||||
segment = self._create_test_segment(db_session_with_containers, account, tenant, dataset, document)
|
||||
segments.append(segment)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user