import inspect
from src import gui_2

def test_refresh_registry_button_calls_load_registry():
 src = inspect.getsource(gui_2)
 marker = "Refresh Registry"
 idx = src.find(marker)
 assert idx != -1, "Could not find Refresh Registry button in gui_2.py"
 snippet = src[idx:idx + 400]
 assert "load_registry" in snippet, (
  "Refresh Registry button must invoke load_registry(); "
  "currently it only re-instantiates LogRegistry which leaves .data empty."
 )
 assert snippet.count("log_registry.LogRegistry(") <= 1, (
  "Refresh Registry button should not re-instantiate LogRegistry. "
  "Prefer in-place load_registry() on the live instance."
 )
