diff options
author | BonfaceKilz | 2022-03-14 18:01:02 +0300 |
---|---|---|
committer | BonfaceKilz | 2022-03-14 18:01:02 +0300 |
commit | a4ffdf5caced76f720b44f2b3ccd13a9be6f7040 (patch) | |
tree | 36d770f59b1b2ffe237c4fb7a588c796371df516 /tests | |
parent | 046f184c63c48c19e4d807032623e5a4bfaaac3b (diff) | |
download | genenetwork3-a4ffdf5caced76f720b44f2b3ccd13a9be6f7040.tar.gz |
Get all permissible column data
* gn3/csvcmp.py: Import "Any" and "List".
(get_allowable_sampledata_headers): New function.
* tests/unit/test_csvcmp: Import "get_allowable_sampledata_headers".
(test_get_allowable_csv_headers): Test case for the above.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/unit/test_csvcmp.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/unit/test_csvcmp.py b/tests/unit/test_csvcmp.py index c7ffe2f..984a61f 100644 --- a/tests/unit/test_csvcmp.py +++ b/tests/unit/test_csvcmp.py @@ -3,6 +3,7 @@ import pytest from gn3.csvcmp import csv_diff from gn3.csvcmp import fill_csv +from gn3.csvcmp import get_allowable_sampledata_headers from gn3.csvcmp import remove_insignificant_edits from gn3.csvcmp import extract_strain_name @@ -113,3 +114,21 @@ def test_extract_strain_name(): extract_strain_name(csv_header="Strain Name,Value,SE,Count", data="BXD1,18,x,0") == "BXD1" ) + + +@pytest.mark.unit_test +def test_get_allowable_csv_headers(mocker): + """Test that all the csv headers are fetched properly""" + mock_conn = mocker.MagicMock() + expected_values = [ + "Strain Name", "Value", "SE", "Count", + "Condition", "Tissue", "Sex", "Age", + "Ethn.", "PMI (hrs)", "pH", "Color", + ] + with mock_conn.cursor() as cursor: + cursor.fetchall.return_value = ( + ('Condition',), ('Tissue',), ('Sex',), + ('Age',), ('Ethn.',), ('PMI (hrs)',), ('pH',), ('Color',)) + assert get_allowable_sampledata_headers(mock_conn) == expected_values + cursor.execute.assert_called_once_with( + "SELECT Name from CaseAttribute") |