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.2 KB
Raw Blame
from posthog.test.base import BaseTest

from langchain_core.runnables import RunnableConfig

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

from ee.hogai.core.node import AssistantNode
from ee.hogai.utils.types import AssistantState, PartialAssistantState


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

        class Node(AssistantNode):
            def run(self, state: AssistantState, config: RunnableConfig) -> PartialAssistantState | None:
                raise NotImplementedError

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

    def test_core_memory_when_exists(self):
        core_memory = CoreMemory.objects.create(team=self.team, text="Test memory")
        self.assertEqual(self.node.core_memory, core_memory)

    def test_core_memory_when_does_not_exist(self):
        self.assertIsNone(self.node.core_memory)

    def test_product_core_memory_when_exists(self):
        CoreMemory.objects.create(team=self.team, text="Test memory")
        self.assertEqual(self.node.core_memory_text, "Test memory")

    def test_product_core_memory_when_does_not_exist(self):
        self.assertEqual(self.node.core_memory_text, "")