Spaces:
Running
Running
Download tests/test_app.py from Liisdotcom/simulator: direct link, hf CLI and curl.
- Browser
- Download file 2.47 kB
-
https://huggingface.co/spaces/Liisdotcom/simulator/resolve/main/tests/test_app.py
- Command line
-
hf download hf://spaces/Liisdotcom/simulator/tests/test_app.py
-
curl -L -o test_app.py https://huggingface.co/spaces/Liisdotcom/simulator/resolve/main/tests/test_app.py
2.47 kB
| """Smoke tests for the Streamlit app.""" | |
| import pytest | |
| from pathlib import Path | |
| import sys | |
| class TestAppImports: | |
| """Test that app can be imported without errors.""" | |
| def test_yaml_importable(self): | |
| """YAML library is available.""" | |
| import yaml | |
| assert yaml is not None | |
| def test_pandas_importable(self): | |
| """Pandas is available.""" | |
| import pandas as pd | |
| assert pd is not None | |
| def test_plotly_importable(self): | |
| """Plotly is available.""" | |
| import plotly.graph_objects as go | |
| assert go is not None | |
| class TestConfigLoading: | |
| """Test that product configs can be loaded.""" | |
| def test_products_directory_exists(self, products_dir): | |
| """Products directory exists.""" | |
| assert products_dir.exists() | |
| assert products_dir.is_dir() | |
| def test_at_least_one_product(self, all_configs): | |
| """At least one product config exists.""" | |
| assert len(all_configs) > 0 | |
| def test_besafe_config_loadable(self, besafe_config): | |
| """BeSafe config loads successfully.""" | |
| assert besafe_config is not None | |
| assert "product" in besafe_config | |
| def test_hamax_config_loadable(self, hamax_config): | |
| """Hamax config loads successfully.""" | |
| assert hamax_config is not None | |
| assert "product" in hamax_config | |
| class TestProductDetails: | |
| """Test product-specific details are correct.""" | |
| def test_besafe_is_car_seat(self, besafe_config): | |
| """BeSafe is categorized as car seat.""" | |
| assert besafe_config["product"]["category"] == "car_seat" | |
| def test_hamax_is_bicycle_trailer(self, hamax_config): | |
| """Hamax is categorized as bicycle trailer.""" | |
| assert hamax_config["product"]["category"] == "bicycle_trailer" | |
| def test_products_have_images(self, all_configs): | |
| """All products have image URLs.""" | |
| for name, config in all_configs.items(): | |
| assert "image_url" in config["product"], f"{name}: Missing image_url" | |
| assert config["product"]["image_url"].startswith("http"), \ | |
| f"{name}: image_url should be a URL" | |
| def test_products_have_features(self, all_configs): | |
| """All products have feature lists.""" | |
| for name, config in all_configs.items(): | |
| assert "features" in config["product"], f"{name}: Missing features" | |
| assert len(config["product"]["features"]) > 0, f"{name}: Empty features list" | |