aboutsummaryrefslogtreecommitdiff
path: root/tests/unit/db/test_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 /tests/unit/db/test_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 'tests/unit/db/test_sample_data.py')
-rw-r--r--tests/unit/db/test_sample_data.py23
1 files changed, 14 insertions, 9 deletions
diff --git a/tests/unit/db/test_sample_data.py b/tests/unit/db/test_sample_data.py
index 84ab1a1..0fa2604 100644
--- a/tests/unit/db/test_sample_data.py
+++ b/tests/unit/db/test_sample_data.py
@@ -84,17 +84,22 @@ def test_extract_actions():
updated_data="BXD1,x,2,1,F",
csv_header="Strain Name,Value,SE,Count,Sex") ==
{
- "delete": {"data": "18", "csv_header": "Value"},
- "insert": {"data": "2,F", "csv_header": "SE,Sex"},
- "update": {"data": "1", "csv_header": "Count"},
+ "delete": {"data": "BXD1,18",
+ "csv_header": "Strain Name,Value"},
+ "insert": {"data": "BXD1,2,F",
+ "csv_header": "Strain Name,SE,Sex"},
+ "update": {"data": "BXD1,1",
+ "csv_header": "Strain Name,Count"},
})
assert(__extract_actions(original_data="BXD1,18,x,0,x",
updated_data="BXD1,19,2,1,F",
csv_header="Strain Name,Value,SE,Count,Sex") ==
{
"delete": None,
- "insert": {"data": "2,F", "csv_header": "SE,Sex"},
- "update": {"data": "19,1", "csv_header": "Value,Count"},
+ "insert": {"data": "BXD1,2,F",
+ "csv_header": "Strain Name,SE,Sex"},
+ "update": {"data": "BXD1,19,1",
+ "csv_header": "Strain Name,Value,Count"},
})
@@ -119,14 +124,14 @@ def test_update_sample_data(mocker):
gn3.db.sample_data.insert_sample_data.assert_called_once_with(
conn=mock_conn,
trait_name=35,
- data="2,F",
- csv_header="SE,Sex",
+ data="BXD1,2,F",
+ csv_header="Strain Name,SE,Sex",
phenotype_id=10007)
gn3.db.sample_data.delete_sample_data.assert_called_once_with(
conn=mock_conn,
trait_name=35,
- data="18",
- csv_header="Value",
+ data="BXD1,18",
+ csv_header="Strain Name,Value",
phenotype_id=10007)
cursor.execute.assert_has_calls(
[mocker.call("UPDATE NStrain SET count = %s "