MCPcopy Create free account
hub / github.com/OpenRaiser/PaperFlow / test_db_path

Function test_db_path

tests/conftest.py:13–67  ·  view source on GitHub ↗

Create a temporary database for testing

(tmp_path)

Source from the content-addressed store, hash-verified

11 """Create a temporary database for testing"""
12 db_path = tmp_path / "test_paperflow.db"
13 conn = sqlite3.connect(db_path)
14 cursor = conn.cursor()
15
16 # Create tables
17 cursor.execute("""
18 CREATE TABLE profiles (
19 id INTEGER PRIMARY KEY AUTOINCREMENT,
20 user_id TEXT UNIQUE NOT NULL,
21 profile_json TEXT NOT NULL,
22 version TEXT NOT NULL,
23 updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
24 )
25 """)
26
27 cursor.execute("""
28 CREATE TABLE papers (
29 id INTEGER PRIMARY KEY AUTOINCREMENT,
30 arxiv_id TEXT UNIQUE,
31 doi TEXT,
32 title TEXT NOT NULL,
33 authors TEXT,
34 institution TEXT,
35 abstract TEXT,
36 venue TEXT,
37 publish_date DATE,
38 embedding BLOB,
39 embedding_model TEXT,
40 fetched_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
41 pushed BOOLEAN DEFAULT FALSE,
42 push_date DATE
43 )
44 """)
45
46 cursor.execute("""
47 CREATE TABLE behavior_logs (
48 id INTEGER PRIMARY KEY AUTOINCREMENT,
49 user_id TEXT NOT NULL,
50 push_id TEXT NOT NULL,
51 paper_id INTEGER,
52 action TEXT NOT NULL,
53 action_type TEXT NOT NULL,
54 category TEXT,
55 timestamp TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
56 metadata TEXT,
57 FOREIGN KEY (paper_id) REFERENCES papers(id)
58 )
59 """)
60
61 conn.commit()
62 conn.close()
63
64 return str(db_path)
65
66
67@pytest.fixture
68def sample_profile():
69 """Sample user profile for testing"""
70 return {

Callers

nothing calls this directly

Calls 3

cursorMethod · 0.80
executeMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected