aboutsummaryrefslogtreecommitdiff
path: root/tests/unit
diff options
context:
space:
mode:
authorBonfaceKilz2022-02-25 11:37:00 +0300
committerBonfaceKilz2022-03-12 15:33:09 +0300
commit0c1a6fb91b8bf9cf2b68ba54d8905e4c6acfd341 (patch)
treee612932d3e5d35532a7c2b5a12d27a8a01a563a1 /tests/unit
parent5583d16ab678b4420ed4fe9f56f409292e902b29 (diff)
downloadgenenetwork3-0c1a6fb91b8bf9cf2b68ba54d8905e4c6acfd341.tar.gz
Test edges cases for csv files when running csvdiff
* tests/unit/test_csvcmp.py (test_csv_diff): Delete it. (test_csv_diff_same_columns): Test csv_diff against csv texts with the same columns. (test_csv_diff_different_columns): Test csv texts against csv texts with different varying columns.
Diffstat (limited to 'tests/unit')
-rw-r--r--tests/unit/test_csvcmp.py41
1 files changed, 31 insertions, 10 deletions
diff --git a/tests/unit/test_csvcmp.py b/tests/unit/test_csvcmp.py
index 716adb5..023415d 100644
--- a/tests/unit/test_csvcmp.py
+++ b/tests/unit/test_csvcmp.py
@@ -46,13 +46,34 @@ def test_remove_insignificant_data():
@pytest.mark.unit_test
-def test_csv_diff():
- test_results = csv_diff(base_csv="a,b\n1,2\n",
- delta_csv="a,b\n1,3")
- _json = {
- 'Additions': [],
- 'Deletions': [],
- 'Modifications': [{'Current': '1,3', 'Original': '1,2'}]
- }
- assert(test_results.get("code") == 0 and
- test_results.get("output") == _json)
+def test_csv_diff_same_columns():
+ assert(csv_diff(base_csv="a,b\n1,2\n",
+ delta_csv="a,b\n1,3") == {
+ 'Additions': [],
+ 'Deletions': [],
+ 'Columns': '',
+ 'Modifications': [{'Current': '1,3',
+ 'Original': '1,2'}]})
+
+
+@pytest.mark.unit_test
+def test_csv_diff_different_columns():
+ base_csv = """
+Strain Name,Value,SE,Count
+BXD1,18,x,0
+BXD12,16,x,x
+BXD14,15,x,x
+BXD15,14,x,x
+"""
+ delta_csv = """Strain Name,Value,SE,Count,Sex
+BXD1,18,x,0
+BXD12,16,x,x,1
+BXD14,15,x,x
+BXD15,14,x,x"""
+ assert(csv_diff(base_csv=base_csv,
+ delta_csv=delta_csv) == {
+ 'Additions': [],
+ 'Columns': 'Strain Name,Value,SE,Count,Sex',
+ 'Deletions': [],
+ 'Modifications': [{'Current': 'BXD12,16,x,x,1',
+ 'Original': 'BXD12,16,x,x,x'}]})