import unittest
import uuid


from analogai.deepthink.tests.functional.storage_cleaner import cleanup_storages
from analogai.deepthink.startup.bootstrap import create_deepthink_engine
from analogai.deepthink.application.value_objects.user_agent import UserAgent
from analogai.deepthink.presentation.preprocessing.previous_messages_stack import PreviousMessagesStack


class BaseThinkerE2ETest(unittest.TestCase):
    @classmethod
    def setUpClass(cls):
        cls._deepthink = create_deepthink_engine()

    def setUp(self):
        cleanup_storages()
        self._user_id = str(uuid.uuid4())
        self._agent_id = str(uuid.uuid4())
        self._user_agent = UserAgent(
            user_id=self._user_id,
            agent_id=self._agent_id,
            user_authority=1.0,
        )
        self._stack = PreviousMessagesStack()

    def tearDown(self):
        cleanup_storages()

    def _think(self, message: str) -> str | None:
        return self._deepthink.deepthink(
            message,
            user_agent=self._user_agent,
            previous_messages_stack=self._stack,
        )
