trustgraph/tests/unit/test_cli
Sunny Yang cfbd5b9079
feat: export/import workspace knowledge in .tgx bundles (#877 Phase 2) (#1024)
* feat: streaming N-Quads serializer for wire-format triples

Groundwork for Phase 2 of #877 (knowledge export). Hand-rolled
N-Triples term encoding: rdflib's term.n3() emits Turtle-style forms
(numeric shorthand, unescaped newlines) that are invalid in
line-oriented N-Quads, so literals are escaped per the ECHAR grammar
and IRIs validated for representability. Round-trip tests parse the
output back with rdflib's nquads parser and compare term-for-term.

* feat: export/import workspace knowledge in .tgx bundles (#877)

Phase 2 of the workspace bundle commands: tg-export-workspace now
includes the workspace's knowledge by default — per-collection
knowledge-graph triples as N-Quads (the collection names the graph,
streamed through a tempfile so memory stays flat regardless of
knowledge-base size) and the document library (metadata plus content,
fetched one document at a time). --config-only skips knowledge on both
sides; --triples-limit bounds very large graphs; -f/--flow-id selects
the flow the triples services run through.

tg-import-workspace streams triples back through the bulk import per
collection and recreates library documents (children after parents).
Knowledge import is additive, unlike config's skip-existing semantics.
Embedding vectors are not carried in bundles: --process re-runs
imported documents through the flow, which regenerates extraction
output and embeddings; --process-collection targets it.

Round-trip covered by unit tests over real archives: export with a
mocked Api, re-import, and assert the bulk triples stream and library
add calls reproduce the original values (including datatyped literals
via the N-Quads path).
2026-07-06 10:45:23 +01:00
..
__init__.py Knowledge load utility CLI (#456) 2025-08-13 16:07:58 +01:00
conftest.py feat: export/import workspace knowledge in .tgx bundles (#877 Phase 2) (#1024) 2026-07-06 10:45:23 +01:00
test_config_commands.py feat: workspace-based multi-tenancy, replacing user as tenancy axis (#840) 2026-04-21 23:23:01 +01:00
test_error_handling_edge_cases.py Structured data, minor features (#500) 2025-09-05 17:25:12 +01:00
test_load_knowledge.py feat: workspace-based multi-tenancy, replacing user as tenancy axis (#840) 2026-04-21 23:23:01 +01:00
test_load_structured_data.py Structured data, minor features (#500) 2025-09-05 17:25:12 +01:00
test_nquads.py feat: export/import workspace knowledge in .tgx bundles (#877 Phase 2) (#1024) 2026-07-06 10:45:23 +01:00
test_schema_descriptor_generation.py Structured data, minor features (#500) 2025-09-05 17:25:12 +01:00
test_tool_commands.py feat: workspace-based multi-tenancy, replacing user as tenancy axis (#840) 2026-04-21 23:23:01 +01:00
test_workspace_bundle_commands.py feat: export/import workspace knowledge in .tgx bundles (#877 Phase 2) (#1024) 2026-07-06 10:45:23 +01:00
test_xml_xpath_parsing.py Structured data, minor features (#500) 2025-09-05 17:25:12 +01:00