You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
motief/tests/test_home_import.py

38 lines
1.2 KiB

"""Smoke test: Home module is importable without DB or heavy computation."""
import importlib
import sys
def test_home_importable():
# Streamlit cannot run navigation outside of a server context,
# so we only verify the file can be parsed/compiled, not fully executed.
import ast
import os
home_path = os.path.join(os.path.dirname(os.path.dirname(__file__)), "Home.py")
with open(home_path) as f:
source = f.read()
# Verify the file parses as valid Python
tree = ast.parse(source)
# Verify st.navigation is called (modern Streamlit multi-page API)
nav_calls = [
node
for node in ast.walk(tree)
if isinstance(node, ast.Call)
and isinstance(node.func, ast.Attribute)
and node.func.attr == "navigation"
]
assert nav_calls, "Home.py must call st.navigation()"
# Verify at least 2 st.Page() calls exist (one per page)
page_calls = [
node
for node in ast.walk(tree)
if isinstance(node, ast.Call)
and isinstance(node.func, ast.Attribute)
and node.func.attr == "Page"
]
assert len(page_calls) >= 2, "Home.py must define at least 2 st.Page() pages"