style: wrap long lines in tests
Split long docstrings and SQL literals (values unchanged) and drop the unused os import from test_path_security.
This commit is contained in:
@@ -92,7 +92,8 @@ class FakeAutotagService:
|
||||
|
||||
|
||||
class AutotagAPITestCase(AioHTTPTestCase):
|
||||
"""Stands up the PromptManager routes with a temp DB, temp output dir and a fake engine."""
|
||||
"""Stands up the PromptManager routes with a temp DB, temp output dir and a
|
||||
fake engine."""
|
||||
|
||||
async def get_application(self):
|
||||
self._temp_db = tempfile.NamedTemporaryFile(delete=False, suffix=".db")
|
||||
|
||||
@@ -139,7 +139,8 @@ class TestIdempotentMigrations(MigrationTestCase):
|
||||
def test_stale_prompts_new_from_a_failed_rebuild_does_not_block_startup(self):
|
||||
self._legacy_db(
|
||||
[
|
||||
"INSERT INTO prompts (text, hash, workflow_name) VALUES ('a', 'h1', 'wf')",
|
||||
"INSERT INTO prompts (text, hash, workflow_name)"
|
||||
" VALUES ('a', 'h1', 'wf')",
|
||||
"CREATE TABLE prompts_new (id INTEGER PRIMARY KEY, junk TEXT)",
|
||||
"INSERT INTO prompts_new (junk) VALUES ('leftover')",
|
||||
]
|
||||
@@ -155,7 +156,8 @@ class TestIdempotentMigrations(MigrationTestCase):
|
||||
# DROP TABLE prompts with foreign keys ON cascades into generated_images
|
||||
self._legacy_db(
|
||||
[
|
||||
"INSERT INTO prompts (text, hash, workflow_name) VALUES ('a', 'h1', 'wf')",
|
||||
"INSERT INTO prompts (text, hash, workflow_name)"
|
||||
" VALUES ('a', 'h1', 'wf')",
|
||||
"INSERT INTO generated_images (prompt_id, image_path, filename)"
|
||||
" VALUES (1, '/out/a.png', 'a.png')",
|
||||
]
|
||||
@@ -193,7 +195,8 @@ class TestIdempotentMigrations(MigrationTestCase):
|
||||
LEGACY_IMAGES_TABLE.replace("prompt_id INTEGER", "prompt_id TEXT")
|
||||
)
|
||||
conn.execute(
|
||||
"INSERT INTO prompts (text, hash, workflow_name) VALUES ('a', 'h1', 'wf')"
|
||||
"INSERT INTO prompts (text, hash, workflow_name)"
|
||||
" VALUES ('a', 'h1', 'wf')"
|
||||
)
|
||||
for prompt_id, name in (
|
||||
("1", "ok.png"),
|
||||
@@ -234,7 +237,8 @@ class TestIdempotentMigrations(MigrationTestCase):
|
||||
def test_image_table_is_rebuilt_with_uniqueness_by_full_path(self):
|
||||
self._legacy_db(
|
||||
[
|
||||
"INSERT INTO prompts (text, hash, workflow_name) VALUES ('a', 'h1', 'wf')",
|
||||
"INSERT INTO prompts (text, hash, workflow_name)"
|
||||
" VALUES ('a', 'h1', 'wf')",
|
||||
# same basename in two folders: both must survive
|
||||
"INSERT INTO generated_images (prompt_id, image_path, filename)"
|
||||
" VALUES (1, '/out/2026-01-01/a.png', 'a.png')",
|
||||
|
||||
@@ -53,7 +53,8 @@ class TestPromptManagerTextEmptyInput(unittest.TestCase):
|
||||
def test_empty_text_with_prepend_append(
|
||||
self, mock_db, mock_integ, mock_tracker, mock_monitor
|
||||
):
|
||||
"""Empty main text with prepend/append should produce single space, not double."""
|
||||
"""Empty main text with prepend/append should produce single space, not
|
||||
double."""
|
||||
node = self._make_node(mock_db, mock_integ, mock_tracker, mock_monitor)
|
||||
result = node.process_text(text="", prepend_text="before", append_text="after")
|
||||
self.assertIsInstance(result, tuple)
|
||||
@@ -128,7 +129,8 @@ class TestPromptManagerEmptyInput(unittest.TestCase):
|
||||
def test_empty_text_with_prepend_append(
|
||||
self, mock_db, mock_integ, mock_tracker, mock_monitor
|
||||
):
|
||||
"""Empty main text with prepend/append should produce single space, not double."""
|
||||
"""Empty main text with prepend/append should produce single space, not
|
||||
double."""
|
||||
node, clip = self._make_node_and_clip(
|
||||
mock_db, mock_integ, mock_tracker, mock_monitor
|
||||
)
|
||||
|
||||
@@ -52,7 +52,8 @@ class TestMonitorSingletonLifecycle(unittest.TestCase):
|
||||
self.assertIs(m1, m2)
|
||||
|
||||
def test_singleton_survives_across_different_callers(self):
|
||||
"""Different db/tracker args on subsequent calls still return the same instance."""
|
||||
"""Different db/tracker args on subsequent calls still return the same
|
||||
instance."""
|
||||
db1, tracker1 = MagicMock(), MagicMock()
|
||||
db2, tracker2 = MagicMock(), MagicMock()
|
||||
|
||||
|
||||
@@ -34,7 +34,8 @@ class TestFindComfyuiOutputDir(unittest.TestCase):
|
||||
GalleryConfig.MONITORING_DIRECTORIES = self._orig_dirs
|
||||
|
||||
def test_configured_directory_takes_priority(self):
|
||||
"""When a valid directory is configured, it should be used instead of auto-detect."""
|
||||
"""When a valid directory is configured, it should be used instead of
|
||||
auto-detect."""
|
||||
with tempfile.TemporaryDirectory() as tmpdir:
|
||||
GalleryConfig.MONITORING_DIRECTORIES = [tmpdir]
|
||||
self.api._cached_output_dir = None
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
"""Tests for path traversal and symlink security in image serving."""
|
||||
|
||||
import os
|
||||
import tempfile
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
@@ -174,7 +174,8 @@ class TestUsageMigration(unittest.TestCase):
|
||||
# generated_images uses SQLite's space-separated CURRENT_TIMESTAMP format
|
||||
for i, ts in enumerate(("2026-03-05 08:00:00", "2026-02-01 09:00:00")):
|
||||
conn.execute(
|
||||
"INSERT INTO generated_images (prompt_id, image_path, filename, generation_time)"
|
||||
"INSERT INTO generated_images"
|
||||
" (prompt_id, image_path, filename, generation_time)"
|
||||
" VALUES (?, ?, ?, ?)",
|
||||
(self.with_images, f"/out/{i}.png", f"{i}.png", ts),
|
||||
)
|
||||
|
||||
@@ -32,7 +32,8 @@ def apply_filters(texts, skip_multipart=True):
|
||||
|
||||
|
||||
class TestNewlineCollapse(unittest.TestCase):
|
||||
"""Newlines must be collapsed so StringOutputList treats each DB entry as one prompt."""
|
||||
"""Newlines must be collapsed so StringOutputList treats each DB entry as one
|
||||
prompt."""
|
||||
|
||||
def test_single_line_unchanged(self):
|
||||
result = apply_filters(["a beautiful landscape"])
|
||||
|
||||
Reference in New Issue
Block a user