Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

1.1 KB
Raw Blame
from posthog.test.base import BaseTest

from products.posthog_ai.backend.models.assistant import CoreMemory

from ee.hogai.core.mixins import AssistantContextMixin


class TestAssistantNodeMixin(BaseTest):
    def setUp(self):
        super().setUp()

        class TestNode(AssistantContextMixin):
            def __init__(self, team, user):
                self._team = team
                self._user = user

        self.node = TestNode(self.team, self.user)

    async def test_aget_core_memory_when_exists(self):
        core_memory = await CoreMemory.objects.acreate(team=self.team, text="Test memory")
        result = await self.node._aget_core_memory()
        self.assertEqual(result, core_memory)

    async def test_aget_core_memory_when_does_not_exist(self):
        result = await self.node._aget_core_memory()
        self.assertIsNone(result)

    async def test_aget_core_memory_text_when_exists(self):
        await CoreMemory.objects.acreate(team=self.team, text="Test memory content")
        result = await self.node._aget_core_memory_text()
        self.assertEqual(result, "Test memory content")