Skip to content

Commit ac61a12

Browse files
removed unwanted comment
1 parent 8cf628d commit ac61a12

File tree

11 files changed

+30
-737
lines changed

11 files changed

+30
-737
lines changed

content-gen/src/tests/agents/test_image_content_agent.py

Lines changed: 2 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,7 @@
1-
"""
2-
Unit tests for Image Content Agent.
3-
4-
Tests cover:
5-
- Prompt truncation for image generation limits
6-
- Image generation via DALL-E 3
7-
- Image generation via gpt-image-1
8-
- Error handling and fallbacks
9-
"""
10-
11-
import pytest
12-
from unittest.mock import AsyncMock, MagicMock, patch
131
import base64
2+
from unittest.mock import AsyncMock, MagicMock, patch
143

15-
16-
# ==================== Truncate For Image Tests ====================
4+
import pytest
175

186
def test_truncate_short_description_unchanged():
197
"""Test that short descriptions are returned unchanged."""
@@ -24,7 +12,6 @@ def test_truncate_short_description_unchanged():
2412

2513
assert result == short_desc
2614

27-
2815
def test_truncate_empty_description():
2916
"""Test handling of empty description."""
3017
from agents.image_content_agent import _truncate_for_image
@@ -35,7 +22,6 @@ def test_truncate_empty_description():
3522
result = _truncate_for_image(None, max_chars=1500)
3623
assert result is None
3724

38-
3925
def test_truncate_long_description_truncated():
4026
"""Test that very long descriptions are truncated."""
4127
from agents.image_content_agent import _truncate_for_image
@@ -46,7 +32,6 @@ def test_truncate_long_description_truncated():
4632
assert len(result) <= 1500
4733
assert "[Additional details truncated for image generation]" in result or len(result) <= 1500
4834

49-
5035
def test_truncate_preserves_hex_codes():
5136
"""Test that hex color codes are preserved in truncation."""
5237
from agents.image_content_agent import _truncate_for_image
@@ -64,7 +49,6 @@ def test_truncate_preserves_hex_codes():
6449

6550
assert "### Product A" in result or "#FF5733" in result or len(result) <= 500
6651

67-
6852
def test_truncate_preserves_product_headers():
6953
"""Test that product headers (### ...) are preserved."""
7054
from agents.image_content_agent import _truncate_for_image
@@ -82,7 +66,6 @@ def test_truncate_preserves_product_headers():
8266

8367
assert len(result) <= 300
8468

85-
8669
def test_truncate_preserves_finish_descriptions():
8770
"""Test that finish descriptions (matte, eggshell) are considered."""
8871
from agents.image_content_agent import _truncate_for_image
@@ -97,9 +80,6 @@ def test_truncate_preserves_finish_descriptions():
9780

9881
assert len(result) <= 400
9982

100-
101-
# ==================== Generate DALL-E Image Tests ====================
102-
10383
@pytest.mark.asyncio
10484
async def test_generate_dalle_image_success():
10585
"""Test successful DALL-E image generation."""
@@ -147,7 +127,6 @@ async def test_generate_dalle_image_success():
147127
assert "image_base64" in result
148128
assert result["model"] == "dall-e-3"
149129

150-
151130
@pytest.mark.asyncio
152131
async def test_generate_dalle_image_with_managed_identity():
153132
"""Test DALL-E generation with managed identity credential."""
@@ -189,7 +168,6 @@ async def test_generate_dalle_image_with_managed_identity():
189168
assert result["success"] is True
190169
mock_cred.assert_called_once_with(client_id="test-client-id")
191170

192-
193171
@pytest.mark.asyncio
194172
async def test_generate_dalle_image_error_handling():
195173
"""Test DALL-E generation error handling."""
@@ -218,9 +196,6 @@ async def test_generate_dalle_image_error_handling():
218196
assert "error" in result
219197
assert "Authentication failed" in result["error"]
220198

221-
222-
# ==================== Generate GPT Image Tests ====================
223-
224199
@pytest.mark.asyncio
225200
async def test_generate_gpt_image_success():
226201
"""Test successful gpt-image-1 generation."""
@@ -267,7 +242,6 @@ async def test_generate_gpt_image_success():
267242
assert "image_base64" in result
268243
assert result["model"] == "gpt-image-1"
269244

270-
271245
@pytest.mark.asyncio
272246
async def test_generate_gpt_image_quality_passthrough():
273247
"""Test that gpt-image passes quality setting through unchanged."""
@@ -309,7 +283,6 @@ async def test_generate_gpt_image_quality_passthrough():
309283
call_kwargs = mock_openai.images.generate.call_args.kwargs
310284
assert call_kwargs["quality"] == "medium"
311285

312-
313286
@pytest.mark.asyncio
314287
async def test_generate_gpt_image_no_b64_falls_back_to_url():
315288
"""Test fallback to URL fetch when b64_json is not available."""
@@ -363,7 +336,6 @@ async def test_generate_gpt_image_no_b64_falls_back_to_url():
363336

364337
assert result["success"] is True
365338

366-
367339
@pytest.mark.asyncio
368340
async def test_generate_gpt_image_error_handling():
369341
"""Test gpt-image error handling."""
@@ -391,9 +363,6 @@ async def test_generate_gpt_image_error_handling():
391363
assert result["success"] is False
392364
assert "error" in result
393365

394-
395-
# ==================== Model Routing Tests ====================
396-
397366
@pytest.mark.asyncio
398367
async def test_routes_to_dalle_for_dalle_model():
399368
"""Test that dall-e-3 model routes to DALL-E generator."""
@@ -413,7 +382,6 @@ async def test_routes_to_dalle_for_dalle_model():
413382
mock_gpt.assert_not_called()
414383
assert result["model"] == "dall-e-3"
415384

416-
417385
@pytest.mark.asyncio
418386
async def test_routes_to_gpt_image_for_gpt_model():
419387
"""Test that gpt-image-1 model routes to gpt-image generator."""
@@ -433,7 +401,6 @@ async def test_routes_to_gpt_image_for_gpt_model():
433401
mock_dalle.assert_not_called()
434402
assert result["model"] == "gpt-image-1"
435403

436-
437404
@pytest.mark.asyncio
438405
async def test_routes_to_gpt_image_for_gpt_image_1_5():
439406
"""Test that gpt-image-1.5 model routes to gpt-image generator."""
@@ -452,9 +419,6 @@ async def test_routes_to_gpt_image_for_gpt_image_1_5():
452419
mock_gpt.assert_called_once()
453420
mock_dalle.assert_not_called()
454421

455-
456-
# ==================== Truncation Edge Case Tests ====================
457-
458422
def test_truncate_preserves_hex_in_middle_of_line():
459423
"""Test hex code in middle of line is preserved."""
460424
from agents.image_content_agent import _truncate_for_image
@@ -469,7 +433,6 @@ def test_truncate_preserves_hex_in_middle_of_line():
469433
# Should contain some hex reference
470434
assert len(result) <= 400
471435

472-
473436
def test_truncate_preserves_description_quotes():
474437
"""Test quoted descriptions with 'appears as' are preserved."""
475438
from agents.image_content_agent import _truncate_for_image
@@ -482,7 +445,6 @@ def test_truncate_preserves_description_quotes():
482445
result = _truncate_for_image(desc, max_chars=500)
483446
assert len(result) <= 500
484447

485-
486448
def test_truncate_with_eggshell_finish():
487449
"""Test that eggshell finish descriptions are considered."""
488450
from agents.image_content_agent import _truncate_for_image
@@ -496,9 +458,6 @@ def test_truncate_with_eggshell_finish():
496458
result = _truncate_for_image(desc, max_chars=400)
497459
assert len(result) <= 400
498460

499-
500-
# ==================== Long Prompt Tests ====================
501-
502461
@pytest.mark.asyncio
503462
async def test_generate_image_truncates_very_long_prompt():
504463
"""Test that _generate_dalle_image truncates very long product descriptions.

0 commit comments

Comments
 (0)