import os

import pytest

os.environ.setdefault("OPENAI_BASE_URL", "http://test/v1")

from src.memory.embedder import embed_texts


@pytest.mark.skipif(not os.environ.get("RUN_LIVE"), reason="needs RUN_LIVE=1")
def test_live_embed_single() -> None:
    r = embed_texts(["hello world"])
    assert len(r) == 1
    assert len(r[0]) > 100


@pytest.mark.skipif(not os.environ.get("RUN_LIVE"), reason="needs RUN_LIVE=1")
def test_live_embed_batch() -> None:
    r = embed_texts(["text one", "text two", "text three"])
    assert len(r) == 3
    assert all(len(emb) > 100 for emb in r)


@pytest.mark.skipif(not os.environ.get("RUN_LIVE"), reason="needs RUN_LIVE=1")
def test_live_embed_qwen3_batch() -> None:
    r = embed_texts([f"text {i}" for i in range(100)])
    assert len(r) == 100
    assert all(len(emb) == 4096 for emb in r)
