from unittest.mock import MagicMock, patch

from GramAddict.core.situational_awareness import SituationalAwarenessEngine


def test_sae_has_unlearn_current_state():
    """Prove that SituationalAwarenessEngine exposes unlearn_current_state to heal from poisoned context."""
    device = MagicMock()
    sae = SituationalAwarenessEngine(device)

    # Mocking internal compression and the screen_memory dependency
    sae._compress_xml = MagicMock(return_value="<compressed_feed/>")

    with patch("GramAddict.core.qdrant_memory.ScreenMemoryDB") as MockScreenMemoryDB:
        mock_db_instance = MockScreenMemoryDB.return_value

        # If unlearn_current_state does not exist, AttributeError (RED)
        sae.unlearn_current_state("<full_feed_xml/>")

        # Verify it compresses and delegates to purge_screen
        sae._compress_xml.assert_called_once_with("<full_feed_xml/>")
        mock_db_instance.purge_screen.assert_called_once_with("<compressed_feed/>")
