aboutsummaryrefslogtreecommitdiff
path: root/gn3/db/sample_data.py
diff options
context:
space:
mode:
authorBonfaceKilz2022-03-11 11:35:34 +0300
committerBonfaceKilz2022-03-12 15:33:09 +0300
commit78f22407ee73c89eb7477e7e025c37c671037ab0 (patch)
treef0d5d92cf0d57e184bf8fd0f11883573c197578f /gn3/db/sample_data.py
parent035520cd5f99fb91540831d4d46b682452675d1b (diff)
downloadgenenetwork3-78f22407ee73c89eb7477e7e025c37c671037ab0.tar.gz
Append the strain name when extracting "actions"
* gn3/db/sample_data.py (__extract_actions): During updates, make sure that the strain name is part of the returned string when extracting "actions". * tests/unit/db/test_sample_data.py: Add test cases for the above.
Diffstat (limited to 'gn3/db/sample_data.py')
-rw-r--r--gn3/db/sample_data.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/gn3/db/sample_data.py b/gn3/db/sample_data.py
index e5c5e48..c697de0 100644
--- a/gn3/db/sample_data.py
+++ b/gn3/db/sample_data.py
@@ -22,7 +22,10 @@ def __extract_actions(original_data: str,
"insert": {"data": [], "csv_header": []},
"update": {"data": [], "csv_header": []},
}
+ strain_name = ""
for _o, _u, _h in zip(original_data, updated_data, csv_header):
+ if _h == "Strain Name":
+ strain_name = _o
if _o == _u: # No change
continue
elif _o and _u == "x": # Deletion
@@ -38,8 +41,10 @@ def __extract_actions(original_data: str,
if not val["data"]:
result[key] = None
else:
- result[key]["data"] = ",".join(result[key]["data"])
- result[key]["csv_header"] = ",".join(result[key]["csv_header"])
+ result[key]["data"] = (f"{strain_name}," +
+ ",".join(result[key]["data"]))
+ result[key]["csv_header"] = ("Strain Name," +
+ ",".join(result[key]["csv_header"]))
return result