import pytest
from unittest.mock import patch, MagicMock
from src.imgui_scopes import _ScopeId
import src.imgui_scopes as imgui_scopes

def test_scope_id_string():
 with patch('src.imgui_scopes.imgui') as mock_imgui:
  sid = _ScopeId("test_id")
  with sid:
   pass
  mock_imgui.push_id.assert_called_once_with("test_id")
  mock_imgui.pop_id.assert_called_once()

def test_scope_id_int():
 with patch('src.imgui_scopes.imgui') as mock_imgui:
  # Python type hint is str, but we test runtime resilience
  sid = _ScopeId(1234)
  with sid:
   pass
  # Verify it was converted to string to prevent low-level crashes
  mock_imgui.push_id.assert_called_once_with("1234")
  mock_imgui.pop_id.assert_called_once()

def test_id_helper_function():
 with patch('src.imgui_scopes.imgui') as mock_imgui:
  with imgui_scopes.id(42):
   pass
  mock_imgui.push_id.assert_called_once_with("42")
  mock_imgui.pop_id.assert_called_once()
