Skip to content

Commit 081a8ba

Browse files
Merge pull request #763 from microsoft/code-quality
refactor: Refactor test assertions and clean up test files
2 parents c7fd67f + 68b22ba commit 081a8ba

5 files changed

Lines changed: 5 additions & 19 deletions

File tree

content-gen/src/tests/conftest.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ def pytest_sessionfinish(session, exitstatus): # noqa: ARG001
6060
if not loop.is_closed():
6161
loop.close()
6262
except Exception:
63+
# Ignore exceptions during event loop cleanup (loop may already be closed)
6364
pass
6465

6566

content-gen/src/tests/services/test_blob_service.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,9 @@ async def test_upload_product_image_png(mock_blob_service_with_containers):
196196
"image/png"
197197
)
198198

199-
assert ".png" in mock_blob_client.url or "image.png" in mock_blob_client.url
199+
assert ".png" in url or "image.png" in url
200+
assert description == "PNG image description"
201+
mock_blob_client.upload_blob.assert_called_once()
200202

201203

202204
@pytest.mark.asyncio

content-gen/src/tests/services/test_orchestrator.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from unittest.mock import AsyncMock, MagicMock, patch
44

55
import pytest
6+
import orchestrator as orch_module
67
from orchestrator import (_HARMFUL_PATTERNS_COMPILED,
78
_SYSTEM_PROMPT_PATTERNS_COMPILED,
89
PLANNING_INSTRUCTIONS, RAI_HARMFUL_CONTENT_RESPONSE,
@@ -838,8 +839,6 @@ def test_get_orchestrator_singleton():
838839
mock_builder_instance.build.return_value = mock_workflow
839840
mock_builder.return_value = mock_builder_instance
840841

841-
import orchestrator as orch_module
842-
843842
# Reset the singleton
844843
orch_module._orchestrator = None
845844

@@ -1517,8 +1516,6 @@ async def test_get_chat_client_foundry_mode():
15171516

15181517
def test_foundry_not_available():
15191518
"""Test when Foundry SDK is not available."""
1520-
import orchestrator as orch_module
1521-
15221519
# Check that FOUNDRY_AVAILABLE is defined
15231520
assert hasattr(orch_module, 'FOUNDRY_AVAILABLE')
15241521

content-gen/tests/e2e-test/pages/HomePage.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
"""Home page object module for Fabric SQL automation tests."""
22
import logging
3-
import json
43
import os
54
import re
65
import math
@@ -9,7 +8,6 @@
98

109
from PIL import Image
1110
from base.base import BasePage
12-
from config.constants import HELLO_PROMPT, GOOD_MORNING_PROMPT, RAI_PROMPT, OUT_OF_SCOPE_PROMPT
1311

1412
from playwright.sync_api import expect
1513

@@ -48,7 +46,6 @@ class HomePage(BasePage):
4846
MORE_OPTIONS = "(//button[@style='min-width: 24px; height: 24px; padding: 2px; color: var(--colorNeutralForeground3);'])[2]"
4947
MORE_OPTIONS_DELETE = "(//button[@style='min-width: 24px; height: 24px; padding: 2px; color: var(--colorNeutralForeground3);'])[3]"
5048
RENAME_OPTION = "//span[normalize-space()='Rename']"
51-
RENAME_OPTION = "//span[normalize-space()='Rename']"
5249
DELETE_CHAT = "//span[normalize-space()='Delete']"
5350
DELETE_BUTTON = "//button[normalize-space()='Delete']"
5451
RENAME_CONVERSATION_INPUT = "//input[@placeholder='Enter conversation name']"

content-gen/tests/e2e-test/tests/conftest.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -194,14 +194,3 @@ def rename_duration_column():
194194

195195
# Register this function to run after everything is done
196196
atexit.register(rename_duration_column)
197-
198-
199-
# Add logs and docstring to report
200-
# @pytest.hookimpl(hookwrapper=True)
201-
# def pytest_runtest_makereport(item, call):
202-
# outcome = yield
203-
# report = outcome.get_result()
204-
# report.description = str(item.function.__doc__)
205-
# os.makedirs("logs", exist_ok=True)
206-
# extra = getattr(report, "extra", [])
207-
# report.extra = extra

0 commit comments

Comments
 (0)