From 78f22407ee73c89eb7477e7e025c37c671037ab0 Mon Sep 17 00:00:00 2001 From: BonfaceKilz Date: Fri, 11 Mar 2022 11:35:34 +0300 Subject: 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. --- tests/unit/db/test_sample_data.py | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) (limited to 'tests/unit') 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 " -- cgit v1.2.3