aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorEugeniy E. Mikhailov <evgmik@gmail.com>2024-05-28 23:00:03 -0400
committerEugeniy E. Mikhailov <evgmik@gmail.com>2024-05-28 23:00:03 -0400
commita68804ebc415b1642fbbeaf10702880da4ab3c88 (patch)
tree91b15017730eb3079cd60730de2bc8d24c6dee2c /tests
parentd78caa866988e18b0b449fbb7ee2f58c516b1d68 (diff)
downloadqolab-a68804ebc415b1642fbbeaf10702880da4ab3c88.tar.gz
qolab-a68804ebc415b1642fbbeaf10702880da4ab3c88.zip
more tests
Diffstat (limited to 'tests')
-rw-r--r--tests/tableflow_test_data/tableOut1nonProcessed.csv8
-rw-r--r--tests/test_tableflow.py21
2 files changed, 24 insertions, 5 deletions
diff --git a/tests/tableflow_test_data/tableOut1nonProcessed.csv b/tests/tableflow_test_data/tableOut1nonProcessed.csv
new file mode 100644
index 0000000..a3bda44
--- /dev/null
+++ b/tests/tableflow_test_data/tableOut1nonProcessed.csv
@@ -0,0 +1,8 @@
+# this is comment line1
+# this is comment line2
+# make sure that the very first column has numbers in it
+x,y,z
+1,2,3
+2,3,4
+4,5,6
+
diff --git a/tests/test_tableflow.py b/tests/test_tableflow.py
index 6b16046..9d6bb3e 100644
--- a/tests/test_tableflow.py
+++ b/tests/test_tableflow.py
@@ -2,23 +2,34 @@ import pytest
import qolab.tableflow as tblfl
import pandas as pd
-def test_noinputs():
+def test_table_load_noinputs():
assert tblfl.loadInOutTables() == (None, None)
assert tblfl.loadInOutTables(inputFileName=None, outputFileName="non_existing_file") == (None, None)
-def test_wrong_comment():
+def test_wrong_comment_in_table_file_to_load():
with pytest.raises(Exception) as exc_info:
# should raise ParserError
tblfl.loadInOutTables(inputFileName='tests/tableflow_test_data/tableIn1.csv', outputFileName=None, comment='%')
-def test_right_comment():
+def test_right_comment_in_table_file_to_load():
tIn,tOut = tblfl.loadInOutTables(inputFileName='tests/tableflow_test_data/tableIn1.csv', outputFileName=None, comment='#')
assert type(tIn) == pd.core.frame.DataFrame
-def test_right_comment():
+def test_table_equality_with_no_output_file_name():
tIn,tOut = tblfl.loadInOutTables(inputFileName='tests/tableflow_test_data/tableIn1.csv', outputFileName=None, comment='#')
assert type(tIn) == pd.core.frame.DataFrame
-
+ assert type(tOut) == pd.core.frame.DataFrame
+ assert tIn.equals(tOut)
+ col0 = tIn.keys()[0]
+ vBefore = tIn.at[0, col0]
+ tIn.at[0, col0] = vBefore + 1
+ assert not tIn.equals(tOut)
+
+def test_table_load_with_in_out_file_names():
+ tIn,tOut = tblfl.loadInOutTables(inputFileName='tests/tableflow_test_data/tableIn1.csv', outputFileName='tests/tableflow_test_data/tableOut1nonProcessed.csv', comment='#')
+ assert type(tIn) == pd.core.frame.DataFrame
+ assert type(tOut) == pd.core.frame.DataFrame
+ assert tIn.equals(tOut)
def test_for_existing_row():
tbl1 = pd.DataFrame( {'a':[1,2,3], 'b':[1,4,6]})