Spaces:
Running
Running
Upload tests/test_app.py with huggingface_hub
Browse files- tests/test_app.py +24 -0
tests/test_app.py
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import pytest
|
| 2 |
+
from mlplo.app import load_model_info, MODE_PRESETS
|
| 3 |
+
from pathlib import Path
|
| 4 |
+
import json
|
| 5 |
+
|
| 6 |
+
def test_load_model_info_fallback():
|
| 7 |
+
info = load_model_info("facebook/bart-large-xsum")
|
| 8 |
+
assert "Fallback Model" in info
|
| 9 |
+
assert "facebook/bart-large-xsum" in info
|
| 10 |
+
|
| 11 |
+
def test_load_model_info_local(tmp_path):
|
| 12 |
+
metrics_dir = tmp_path / "metrics"
|
| 13 |
+
metrics_dir.mkdir()
|
| 14 |
+
metrics_file = metrics_dir / "test_metrics.json"
|
| 15 |
+
metrics_file.write_text(json.dumps({"test_rouge1": 0.45, "test_rougeL": 0.40}))
|
| 16 |
+
|
| 17 |
+
info = load_model_info(str(tmp_path))
|
| 18 |
+
assert "Local Checkpoint" in info
|
| 19 |
+
assert "ROUGE-1" in info
|
| 20 |
+
assert "0.45" in info
|
| 21 |
+
|
| 22 |
+
def test_mode_presets():
|
| 23 |
+
assert "Quick Pulse" in MODE_PRESETS
|
| 24 |
+
assert "max_new_tokens" in MODE_PRESETS["Quick Pulse"]
|