MCPcopy Create free account
hub / github.com/Graphify-Labs/graphify / _dispatch_graphdb_push

Function _dispatch_graphdb_push

tests/test_cli_export.py:212–247  ·  view source on GitHub ↗

Run CLI dispatch with the database exporter replaced by a recorder.

(
    monkeypatch,
    tmp_path: Path,
    *,
    subcmd: str,
    uri: str,
    password_env: str | None = None,
    user: str | None = None,
)

Source from the content-addressed store, hash-verified

210
211
212def _dispatch_graphdb_push(
213 monkeypatch,
214 tmp_path: Path,
215 *,
216 subcmd: str,
217 uri: str,
218 password_env: str | None = None,
219 user: str | None = None,
220) -> tuple[dict[str, object], str]:
221 """Run CLI dispatch with the database exporter replaced by a recorder."""
222 project = tmp_path / "project with spaces"
223 project.mkdir()
224 out = _make_graph(project)
225 monkeypatch.chdir(project)
226
227 import graphify.export as export_module
228 from graphify.cli import dispatch_command
229
230 calls: dict[str, object] = {}
231
232 def fake_push(G, *, uri, user, password, communities):
233 calls.update(uri=uri, user=user, password=password, communities=communities)
234 return {"nodes": G.number_of_nodes(), "edges": G.number_of_edges()}
235
236 monkeypatch.setattr(export_module, f"push_to_{subcmd}", fake_push)
237 secret_env = "FALKORDB_PASSWORD" if subcmd == "falkordb" else "NEO4J_PASSWORD"
238 monkeypatch.delenv(secret_env, raising=False)
239 if password_env is not None:
240 monkeypatch.setenv(secret_env, password_env)
241
242 args = ["graphify", "export", subcmd, "--graph", str(out / "graph.json"), "--push", uri]
243 if user is not None:
244 args.extend(["--user", user])
245 monkeypatch.setattr(sys, "argv", args)
246 dispatch_command("export")
247 return calls, uri
248
249
250@pytest.mark.parametrize(

Calls 2

dispatch_commandFunction · 0.90
_make_graphFunction · 0.70

Tested by

no test coverage detected