MCPcopy
hub / github.com/tirth8205/code-review-graph / large_store

Function large_store

tests/test_visualization.py:326–429  ·  view source on GitHub ↗

Store with enough nodes/communities to test aggregation.

(tmp_path)

Source from the content-addressed store, hash-verified

324
325@pytest.fixture
326def large_store(tmp_path):
327 """Store with enough nodes/communities to test aggregation."""
328 db_path = tmp_path / "large.db"
329 store = GraphStore(db_path)
330
331 # Create nodes across multiple files (simulates a larger codebase)
332 files = [f"src/mod{i}.py" for i in range(5)]
333 for fp in files:
334 file_node = NodeInfo(
335 kind="File", name=fp.split("/")[-1], file_path=fp,
336 line_start=1, line_end=100, language="python",
337 parent_name=None, params=None, return_type=None,
338 modifiers=None, is_test=False, extra={},
339 )
340 store.upsert_node(file_node)
341 # Add some functions per file
342 for j in range(3):
343 func_node = NodeInfo(
344 kind="Function", name=f"func_{j}",
345 file_path=fp, line_start=10 + j * 10, line_end=20 + j * 10,
346 language="python", parent_name=None,
347 params="x", return_type="int",
348 modifiers=None, is_test=False, extra={},
349 )
350 store.upsert_node(func_node)
351 # CONTAINS edge from file to function
352 store.upsert_edge(EdgeInfo(
353 kind="CONTAINS", source=fp,
354 target=f"{fp}::func_{j}",
355 file_path=fp, line=10 + j * 10, extra={},
356 ))
357
358 # Add some cross-file CALLS edges
359 store.upsert_edge(EdgeInfo(
360 kind="CALLS",
361 source="src/mod0.py::func_0",
362 target="src/mod1.py::func_1",
363 file_path="src/mod0.py", line=15, extra={},
364 ))
365 store.upsert_edge(EdgeInfo(
366 kind="CALLS",
367 source="src/mod2.py::func_0",
368 target="src/mod3.py::func_2",
369 file_path="src/mod2.py", line=12, extra={},
370 ))
371 store.upsert_edge(EdgeInfo(
372 kind="CALLS",
373 source="src/mod1.py::func_2",
374 target="src/mod4.py::func_0",
375 file_path="src/mod1.py", line=35, extra={},
376 ))
377
378 # Set community_id on nodes (simulate community detection)
379 store._conn.execute(
380 "UPDATE nodes SET community_id = 0 WHERE file_path IN ('src/mod0.py', 'src/mod1.py')"
381 )
382 store._conn.execute(
383 "UPDATE nodes SET community_id = 1 WHERE file_path IN ('src/mod2.py', 'src/mod3.py')"

Callers

nothing calls this directly

Calls 6

upsert_nodeMethod · 0.95
upsert_edgeMethod · 0.95
commitMethod · 0.95
GraphStoreClass · 0.90
NodeInfoClass · 0.90
EdgeInfoClass · 0.90

Tested by

no test coverage detected