From e3e6d6c9512c106297bca2b844513a9e6c0e5f67 Mon Sep 17 00:00:00 2001 From: Pauline Ribeyre <4224001+paulineribeyre@users.noreply.github.com> Date: Tue, 2 Nov 2021 09:18:24 -0500 Subject: [PATCH] Fix export for non-string array values (#360) --- .secrets.baseline | 4 ++-- sheepdog/utils/transforms/graph_to_doc.py | 4 ++-- tests/integration/datadict/submission/test_endpoints.py | 5 +++++ 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/.secrets.baseline b/.secrets.baseline index 1529648f..29b5a43e 100644 --- a/.secrets.baseline +++ b/.secrets.baseline @@ -3,7 +3,7 @@ "files": null, "lines": null }, - "generated_at": "2021-08-19T20:25:38Z", + "generated_at": "2021-11-01T21:39:46Z", "plugins_used": [ { "name": "AWSKeyDetector" @@ -166,7 +166,7 @@ { "hashed_secret": "78b4db9b2aec0f0f2d3e38f9278be42b861c9dc3", "is_verified": false, - "line_number": 1424, + "line_number": 1473, "type": "Hex High Entropy String" } ], diff --git a/sheepdog/utils/transforms/graph_to_doc.py b/sheepdog/utils/transforms/graph_to_doc.py index f59eb7e2..06cc2def 100644 --- a/sheepdog/utils/transforms/graph_to_doc.py +++ b/sheepdog/utils/transforms/graph_to_doc.py @@ -157,7 +157,7 @@ def list_to_comma_string(val, file_format): Handle array fields by converting them to a comma-separated string. Example: - ['1','2','3'] -> 1,2,3 + ['1','2','3'] -> '1,2,3' """ if val is None: @@ -167,7 +167,7 @@ def list_to_comma_string(val, file_format): return "" if isinstance(val, list): - val = ",".join(val) + val = ",".join((str(x) for x in val)) return val diff --git a/tests/integration/datadict/submission/test_endpoints.py b/tests/integration/datadict/submission/test_endpoints.py index f49a1491..22382df2 100644 --- a/tests/integration/datadict/submission/test_endpoints.py +++ b/tests/integration/datadict/submission/test_endpoints.py @@ -21,6 +21,7 @@ from sheepdog.transactions.upload import UploadTransaction from sheepdog.utils import get_external_proxies from sheepdog.utils.transforms import TSVToJSONConverter +from sheepdog.utils.transforms.graph_to_doc import list_to_comma_string from tests.integration.datadict.submission.utils import ( data_fnames, extended_data_fnames, @@ -819,6 +820,10 @@ def test_export_all_node_types( do_test_export(client, pg_driver, submitter, "experimental_metadata", "tsv") +def test_export_non_string_array_values(): + assert list_to_comma_string(["string", 1, 0.5, True], "tsv") == "string,1,0.5,True" + + def test_export_all_node_types_and_resubmit_json( client, pg_driver, cgci_blgsp, submitter, require_index_exists_off ):