chore: 去掉 Streamlit,只保留一套界面和环境
工具箱只留 Vue 3 + Naive UI,启动改为 start.cmd;依赖合并进 requirements.txt, Python 环境只保留 .venv。
This commit is contained in:
@@ -241,55 +241,5 @@ class TaskIntegrationTest(unittest.TestCase):
|
||||
self.assertTrue(any(l.findtext('layername') == '移动C端采样点比例_AOI' for l in xml.findall('projectlayers/maplayer')))
|
||||
|
||||
|
||||
class PageTest(unittest.TestCase):
|
||||
def test_result_file_list_is_sorted(self):
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
root = Path(directory)
|
||||
(root / "b.zip").write_bytes(b"b")
|
||||
(root / "a.csv").write_text("x\n", encoding="utf-8")
|
||||
(root / ".hidden").write_text("x", encoding="utf-8")
|
||||
from ui.results_page import _file_rows, _task_label
|
||||
names = [path.name for path in _file_rows(root)]
|
||||
self.assertEqual(names, ["a.csv", "b.zip"])
|
||||
self.assertIn("市场网格出图", _task_label({
|
||||
"id": "20260815-a0000001", "kind": "market", "status": "success"
|
||||
}))
|
||||
|
||||
def test_global_css_survives_streamlit_sanitizer(self):
|
||||
# st.html 经 DOMPurify 清洗,样式里出现 "<"(如内联 SVG)会让整段 <style> 被丢弃。
|
||||
from ui.layout import COMPACT_CSS
|
||||
self.assertNotIn("<", COMPACT_CSS)
|
||||
self.assertIn('[data-testid="InputInstructions"]', COMPACT_CSS)
|
||||
|
||||
def test_uploaded_file_is_stored_once_with_exact_bytes(self):
|
||||
from streamlit.testing.v1 import AppTest
|
||||
from ui import inputs
|
||||
content = b"id,longitude,latitude\n1,112,22\n"
|
||||
uploaded = io.BytesIO(content)
|
||||
uploaded.name, uploaded.size, uploaded.file_id = "坐标.csv", len(content), "test-upload"
|
||||
with tempfile.TemporaryDirectory() as directory, patch.object(inputs, "ROOT", Path(directory)), \
|
||||
patch("streamlit.file_uploader", return_value=uploaded):
|
||||
at = AppTest.from_string(
|
||||
"from ui.inputs import file_input\n"
|
||||
"file_input('坐标', 'missing.csv', 'csv', 'test')"
|
||||
).run()
|
||||
at.radio[0].set_value("拖拽上传").run()
|
||||
self.assertFalse(at.exception)
|
||||
saved = list(Path(directory).rglob("坐标.csv"))
|
||||
self.assertEqual(len(saved), 1)
|
||||
self.assertEqual(saved[0].read_bytes(), content)
|
||||
at.run()
|
||||
self.assertEqual(len(list(Path(directory).rglob("坐标.csv"))), 1)
|
||||
|
||||
def test_home_and_each_functional_page_render(self):
|
||||
from streamlit.testing.v1 import AppTest
|
||||
at = AppTest.from_file(str(tasks.ROOT / "app.py")).run(timeout=30)
|
||||
self.assertFalse(at.exception, at.exception)
|
||||
for module in ("market_page", "building_page", "tasks_page", "results_page"):
|
||||
with self.subTest(page=module):
|
||||
at = AppTest.from_string(f"from ui.{module} import render\nrender()").run(timeout=30)
|
||||
self.assertFalse(at.exception, at.exception)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user