eduard/cobra-boards

Cobra Boards, team task boards you can run from Claude or ChatGPT. FastAPI + DataK3 + appid + Dodil Models + MCP.

A remix template · 1 remixes · Remix eduard/cobra-boards

tests/conftest.py

"""Shared test setup: an in-memory repository, a predictable AI, a fixed 'today', and a board with
an owner, a member, a viewer and a stranger who is on nothing."""
import json
from datetime import date

import pytest

from boards.application.use_cases import Boards
from boards.domain.model import Person
from boards.infrastructure.memory import MemoryBoards, MemoryObjects

OWNER, MEMBER, VIEWER, STRANGER = (Person(e) for e in
                                   ("ana@cobra.test", "bo@cobra.test", "cy@cobra.test",
                                    "dee@cobra.test"))
TODAY = date(2026, 11, 10)


class FakeAI:
    """Deterministic stand-in for Dodil Models: same text, same vector."""

    def checklist(self, title, description):
        return ["Draft it", "Review it", "Ship it"]

    def summary(self, board_title, facts):
        return f"Briefing for {board_title}: " + facts.splitlines()[1]

    def embed(self, text):
        words = text.lower().split()
        vocab = ["invoice", "bill", "payment", "launch", "website", "deploy", "design", "logo"]
        v = [float(sum(w.startswith(k) for w in words)) for k in vocab]
        if "invoice" in text.lower() or "bill" in text.lower():
            v[0] += 1
            v[1] += 1
        return v if any(v) else [0.01] * len(vocab)


@pytest.fixture
def svc():
    s = Boards(MemoryBoards(), FakeAI(), today=lambda: TODAY, objects=MemoryObjects())
    b = s.create_board(OWNER, "Launch")
    s.invite(OWNER, b["id"], MEMBER.email, "member")
    s.invite(OWNER, b["id"], VIEWER.email, "viewer")
    return s, b["id"]


def headers(p: Person) -> dict:
    return {"X-Dodil-User": json.dumps({"sub": p.email, "email": p.email})}