"""Smoke test: Home module is importable without DB or heavy computation."""

import importlib
import sys


def test_home_importable():
    # Streamlit cannot run set_page_config 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.set_page_config is called at module level (first Streamlit command)
    calls = [
        node
        for node in ast.walk(tree)
        if isinstance(node, ast.Call)
        and isinstance(node.func, ast.Attribute)
        and node.func.attr == "set_page_config"
    ]
    assert calls, "Home.py must call st.set_page_config()"

    # Verify page links exist (st.page_link calls)
    page_links = [
        node
        for node in ast.walk(tree)
        if isinstance(node, ast.Call)
        and isinstance(node.func, ast.Attribute)
        and node.func.attr == "page_link"
    ]
    assert len(page_links) >= 2, "Home.py must have at least 2 st.page_link() calls"
