Files
Warehouse-Digital-Twin-and-…/tests/unit/test_optional_dependencies.py
T

28 lines
990 B
Python

"""Unit tests verifying that dashboard dependencies remain strictly optional."""
from __future__ import annotations
import pytest
from warehouse_twin.dashboard.data_provider import DashboardDataProvider
from warehouse_twin.dashboard.streamlit_app import HAS_STREAMLIT, run_streamlit_app
def test_dashboard_operates_without_streamlit():
"""Verify that DashboardDataProvider and server function independently of Streamlit."""
dp = DashboardDataProvider()
assert dp is not None
# Data provider does not import streamlit
assert hasattr(dp, "list_experiments")
def test_streamlit_app_handles_missing_dependency():
"""Verify that streamlit_app module handles missing streamlit cleanly."""
if not HAS_STREAMLIT:
# Calling run_streamlit_app without streamlit should exit cleanly or print error
with pytest.raises(SystemExit) as exc:
run_streamlit_app()
assert exc.value.code == 1
else:
assert HAS_STREAMLIT is True