555e282cc4
pi-agent-plugin checks / lint (push) Has been cancelled
pi-agent-plugin checks / test (20) (push) Has been cancelled
pi-agent-plugin checks / test (22) (push) Has been cancelled
pi-agent-plugin checks / build (push) Has been cancelled
TypeScript SDK CI / check_changes (push) Has been cancelled
TypeScript SDK CI / changelog_check (push) Has been cancelled
ci / changelog_check (push) Has been cancelled
ci / check_changes (push) Has been cancelled
ci / build_mem0 (3.10) (push) Has been cancelled
ci / build_mem0 (3.11) (push) Has been cancelled
ci / build_mem0 (3.12) (push) Has been cancelled
CLI Node CI / lint (push) Has been cancelled
CLI Node CI / test (20) (push) Has been cancelled
CLI Node CI / test (22) (push) Has been cancelled
CLI Node CI / build (push) Has been cancelled
CLI Python CI / lint (push) Has been cancelled
CLI Python CI / test (3.10) (push) Has been cancelled
CLI Python CI / test (3.11) (push) Has been cancelled
CLI Python CI / test (3.12) (push) Has been cancelled
CLI Python CI / build (push) Has been cancelled
openclaw checks / lint (push) Has been cancelled
openclaw checks / test (20) (push) Has been cancelled
openclaw checks / test (22) (push) Has been cancelled
openclaw checks / build (push) Has been cancelled
opencode-plugin checks / build (push) Has been cancelled
TypeScript SDK CI / build_ts_sdk (20) (push) Has been cancelled
TypeScript SDK CI / build_ts_sdk (22) (push) Has been cancelled
TypeScript SDK CI / integration_ts_sdk (20) (push) Has been cancelled
TypeScript SDK CI / integration_ts_sdk (22) (push) Has been cancelled
67 lines
1.8 KiB
Python
67 lines
1.8 KiB
Python
"""Shared fixtures for mem0-plugin tests."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import os
|
|
import subprocess
|
|
import sys
|
|
|
|
import pytest
|
|
|
|
SCRIPTS_DIR = os.path.join(os.path.dirname(__file__), "..", "scripts")
|
|
|
|
|
|
@pytest.fixture(autouse=True)
|
|
def _scripts_on_path():
|
|
"""Ensure scripts/ is on sys.path so we can import _project, session_stats, etc."""
|
|
abs_scripts = os.path.abspath(SCRIPTS_DIR)
|
|
if abs_scripts not in sys.path:
|
|
sys.path.insert(0, abs_scripts)
|
|
yield
|
|
if abs_scripts in sys.path:
|
|
sys.path.remove(abs_scripts)
|
|
|
|
|
|
@pytest.fixture(autouse=True)
|
|
def _clean_project_map(monkeypatch):
|
|
"""Remove project_map.json and clear MEM0_PROJECT_ID before each test."""
|
|
monkeypatch.delenv("MEM0_PROJECT_ID", raising=False)
|
|
map_path = os.path.expanduser("~/.mem0/project_map.json")
|
|
if os.path.isfile(map_path):
|
|
os.remove(map_path)
|
|
yield
|
|
if os.path.isfile(map_path):
|
|
os.remove(map_path)
|
|
|
|
|
|
@pytest.fixture()
|
|
def tmp_git_repo(tmp_path):
|
|
"""Create a temp dir with a git repo and HTTPS remote."""
|
|
subprocess.run(["git", "init"], cwd=tmp_path, capture_output=True, check=True)
|
|
subprocess.run(
|
|
["git", "remote", "add", "origin", "https://github.com/mem0ai/mem0.git"],
|
|
cwd=tmp_path,
|
|
capture_output=True,
|
|
check=True,
|
|
)
|
|
return tmp_path
|
|
|
|
|
|
@pytest.fixture()
|
|
def tmp_git_repo_ssh(tmp_path):
|
|
"""Create a temp dir with a git repo and SSH remote."""
|
|
subprocess.run(["git", "init"], cwd=tmp_path, capture_output=True, check=True)
|
|
subprocess.run(
|
|
["git", "remote", "add", "origin", "git@github.com:acme/cool-project.git"],
|
|
cwd=tmp_path,
|
|
capture_output=True,
|
|
check=True,
|
|
)
|
|
return tmp_path
|
|
|
|
|
|
@pytest.fixture()
|
|
def tmp_no_git(tmp_path):
|
|
"""Temp dir with no git repo."""
|
|
return tmp_path
|