Files
wehub-resource-sync 7a0da7932b
Backwards Compatibility / Verify Encryption Constants (push) Waiting to run
Backwards Compatibility / PyPI Version Compatibility (push) Waiting to run
Backwards Compatibility / Database Migration Tests (push) Waiting to run
CodeQL Advanced / Analyze (javascript-typescript) (push) Waiting to run
CodeQL Advanced / Analyze (python) (push) Waiting to run
Docker Tests (Consolidated) / UI Tests (Puppeteer) [research-form] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [research-metrics] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [research-workflow] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [settings-core] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [settings-pages] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [history-news] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [library] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [link-analytics] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [mobile] (push) Blocked by required conditions
Docker Tests (Consolidated) / detect-changes (push) Waiting to run
Docker Tests (Consolidated) / Build Test Image (push) Waiting to run
Docker Tests (Consolidated) / All Pytest Tests + Coverage (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [accessibility] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [api-crud] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [auth-login] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [auth-pages] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [auth-register] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [chat-core] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [chat-lifecycle] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [error-benchmark] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) (push) Blocked by required conditions
Docker Tests (Consolidated) / Accessibility Tests (push) Blocked by required conditions
Docker Tests (Consolidated) / LLM Unit Tests (push) Blocked by required conditions
Docker Tests (Consolidated) / LLM Example Tests (push) Blocked by required conditions
Docker Tests (Consolidated) / Production Image Smoke Test (push) Blocked by required conditions
Docker Tests (Consolidated) / Infrastructure Tests (push) Blocked by required conditions
OSSF Scorecard / OSSF Security Scorecard Analysis (push) Waiting to run
OSV-Scanner (Scheduled) / scan-scheduled (push) Failing after 0s
Create Release / test-gate (push) Has been cancelled
Create Release / release-gate (push) Has been cancelled
Create Release / ci-gate (push) Has been cancelled
Create Release / version-check (push) Has been cancelled
Create Release / e2e-test-gate (push) Has been cancelled
Create Release / responsive-test-gate (push) Has been cancelled
Create Release / compat-test-gate (push) Has been cancelled
Create Release / compose-integration-gate (push) Has been cancelled
Create Release / vulture-gate (push) Has been cancelled
Create Release / build (push) Has been cancelled
Create Release / provenance (push) Has been cancelled
Create Release / prerelease-docker (push) Has been cancelled
Create Release / publish-docker (push) Has been cancelled
Create Release / create-release (push) Has been cancelled
Create Release / cleanup-changelog (push) Has been cancelled
Create Release / trigger-pypi (push) Has been cancelled
Create Release / monitor-pypi (push) Has been cancelled
Create Release / Clean up orphan prerelease tags and signatures (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 13:08:55 +08:00

94 lines
3.0 KiB
Python

"""High-value tests for benchmarks/metrics/visualization.py.
Covers matplotlib unavailable path, figure creation, file saving,
Pareto frontier edge cases, and parameter importance sorting.
"""
import pytest
from unittest.mock import patch
class TestPlotOptimizationHistory:
"""Tests for plot_optimization_history."""
def test_returns_none_when_matplotlib_unavailable(self):
"""Returns None when MATPLOTLIB_AVAILABLE is False."""
with patch(
"local_deep_research.benchmarks.metrics.visualization.MATPLOTLIB_AVAILABLE",
False,
):
from local_deep_research.benchmarks.metrics.visualization import (
plot_optimization_history,
)
result = plot_optimization_history([0.5, 0.6], [0.5, 0.6])
assert result is None
def test_returns_figure_with_valid_data(self):
"""Returns a matplotlib Figure with valid inputs."""
from local_deep_research.benchmarks.metrics.visualization import (
plot_optimization_history,
MATPLOTLIB_AVAILABLE,
)
if not MATPLOTLIB_AVAILABLE:
pytest.skip("matplotlib not installed")
fig = plot_optimization_history([0.3, 0.5, 0.7], [0.3, 0.5, 0.7])
assert fig is not None
import matplotlib.pyplot as plt
plt.close(fig)
def test_saves_to_file_when_output_file_given(self, tmp_path):
"""Saves figure to disk when output_file is provided."""
from local_deep_research.benchmarks.metrics.visualization import (
plot_optimization_history,
MATPLOTLIB_AVAILABLE,
)
if not MATPLOTLIB_AVAILABLE:
pytest.skip("matplotlib not installed")
out = str(tmp_path / "history.png")
fig = plot_optimization_history([0.1, 0.2], [0.1, 0.2], output_file=out)
assert fig is not None
assert (tmp_path / "history.png").exists()
import matplotlib.pyplot as plt
plt.close(fig)
def test_custom_title(self):
"""Custom title is set on the axes."""
from local_deep_research.benchmarks.metrics.visualization import (
plot_optimization_history,
MATPLOTLIB_AVAILABLE,
)
if not MATPLOTLIB_AVAILABLE:
pytest.skip("matplotlib not installed")
fig = plot_optimization_history([0.5], [0.5], title="Custom Title")
assert fig is not None
ax = fig.get_axes()[0]
assert ax.get_title() == "Custom Title"
import matplotlib.pyplot as plt
plt.close(fig)
def test_single_trial(self):
"""Works with a single trial value."""
from local_deep_research.benchmarks.metrics.visualization import (
plot_optimization_history,
MATPLOTLIB_AVAILABLE,
)
if not MATPLOTLIB_AVAILABLE:
pytest.skip("matplotlib not installed")
fig = plot_optimization_history([0.9], [0.9])
assert fig is not None
import matplotlib.pyplot as plt
plt.close(fig)