diff --git a/robosystems_client/clients/ledger_client.py b/robosystems_client/clients/ledger_client.py index 9da3896..0e2ffc9 100644 --- a/robosystems_client/clients/ledger_client.py +++ b/robosystems_client/clients/ledger_client.py @@ -786,6 +786,7 @@ # ``ReportDownloadFormat`` enum names used as query variables. _DOWNLOAD_FORMAT_ALIASES = { "holon-jsonld": "HOLON_JSONLD", + "holon-jsonld-lineage": "HOLON_JSONLD_LINEAGE", "xbrl-2.1": "XBRL_2_1", "tavi": "TAVI", } @@ -3782,8 +3783,12 @@ def download_report_bundle( format: Serialization flavor — ``"holon-jsonld"`` (default, the dataset-form scene/boundary/projection holon, which carries the whole report and is stamped at publish), ``"tavi"`` (the - Project Tavi compiled model), or ``"xbrl-2.1"``. The enum names ``"TAVI"`` / - ``"HOLON_JSONLD"`` / ``"XBRL_2_1"`` are also accepted. + Project Tavi compiled model), ``"xbrl-2.1"``, or + ``"holon-jsonld-lineage"`` (the holon with its ``#lineage`` graph: + the ledger lines, entries and events behind every frozen figure, + for this graph's own members). The enum names ``"TAVI"`` / + ``"HOLON_JSONLD"`` / ``"HOLON_JSONLD_LINEAGE"`` / ``"XBRL_2_1"`` + are also accepted. to: Optional file path to write the bytes to. When set, the returned ``ReportBundleDownload.path`` points at the written file. @@ -3830,6 +3835,7 @@ def download_report_bundle( default_ext = { "XBRL_2_1": "zip", "HOLON_JSONLD": "holon.jsonld", + "HOLON_JSONLD_LINEAGE": "lineage.holon.jsonld", }.get(gql_format, "tavi.json") filename = ( _parse_filename(artifact.headers.get("content-disposition", "")) diff --git a/tests/test_ledger_client.py b/tests/test_ledger_client.py index 347c773..864b33d 100644 --- a/tests/test_ledger_client.py +++ b/tests/test_ledger_client.py @@ -3252,6 +3252,28 @@ def test_default_download_is_the_holon(self, mock_client_cls, mock_config, graph # The bytes come from following the presigned URL. assert mock_client.get.call_args.args[0].startswith("https://s3.example.com/") + @patch("robosystems_client.clients.ledger_client.httpx.Client") + def test_lineage_download_takes_the_short_alias( + self, mock_client_cls, mock_config, graph_id + ): + """``holon-jsonld-lineage`` names the lineage holon; with no filename from + the server it lands as ``.lineage.holon.jsonld``, never ``.tavi.json``.""" + artifact = self._mock_artifact(b'{"@graph": []}', "") + artifact.headers = {} + self._patch_httpx(mock_client_cls, artifact) + with patch.object( + LedgerClient, + "_query", + return_value=self._gql_data("application/ld+json", "holon-jsonld-lineage", gen=3), + ) as mock_query: + result = LedgerClient(mock_config).download_report_bundle( + graph_id, "rpt_01", format="holon-jsonld-lineage" + ) + + assert mock_query.call_args.args[2]["format"] == "HOLON_JSONLD_LINEAGE" + assert result.format == "holon-jsonld-lineage" + assert result.filename == "rpt_01-g3.lineage.holon.jsonld" + @patch("robosystems_client.clients.ledger_client.httpx.Client") def test_xbrl_download_follows_presigned_url( self, mock_client_cls, mock_config, graph_id