aboutsummaryrefslogtreecommitdiff
path: root/tests/test_tableflow.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_tableflow.py')
-rw-r--r--tests/test_tableflow.py32
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/test_tableflow.py b/tests/test_tableflow.py
index fce3449..fd52525 100644
--- a/tests/test_tableflow.py
+++ b/tests/test_tableflow.py
@@ -78,7 +78,39 @@ def test_isRedoNeeded():
def test_reflowTable():
tIn,tOut = tblfl.loadInOutTables(inputFileName='tests/tableflow_test_data/tableIn1.csv', outputFileName='tests/tableflow_test_data/tableOut1pariallyProcessed.csv', comment='#')
tOutRef = tOut.copy()
+ # check for warnings
with pytest.warns(UserWarning):
tblfl.reflowTable(tIn,tOut)
+ with pytest.warns(UserWarning):
+ tblfl.reflowTable(tIn,tOut,postProcessedColums=['dummyName'])
+
+ def frow(row):
+ return row
+ with pytest.warns(UserWarning):
+ tblfl.reflowTable(tIn,tOut, process_row_func=frow)
+
+ # now run reflow
+ def frow(row, extraInfo=None):
+ row['out1'] = row['x']*row['x']
+ return row
+ assert len(tIn) != len(tOut)
+ tblfl.reflowTable(tIn,tOut, process_row_func=frow, postProcessedColums=['out1','out2'])
+ assert len(tIn) == len(tOut)
+ assert (tOut['out1'] == tOut['x']*tOut['x']).all()
+
+ # check that reflow is done
+ tOut.loc[tOut['x']==1, 'out1'] = pd.NA
+ tblfl.reflowTable(tIn,tOut, process_row_func=frow, postProcessedColums=['out1','out2'])
+ assert (tOut['out1'] == tOut['x']*tOut['x']).all()
+
+ # check that reflow is not reprocessed
+ tOut.loc[tOut['x']==1, 'out1'] = 12121 # crazy number
+ tblfl.reflowTable(tIn,tOut, process_row_func=frow, postProcessedColums=['out1','out2'])
+ assert (tOut.loc[tOut['x']==1, 'out1'] == 12121).all() # should not change
+ # now we are forcing redo
+ tOut.loc[tOut['x']==1, 'out1'] = 12121 # crazy number
+ tblfl.reflowTable(tIn,tOut, process_row_func=frow, postProcessedColums=['out1','out2'], redo=True)
+ assert not (tOut.loc[tOut['x']==1, 'out1'] == 12121).all() # must not be the same
+ assert (tOut['out1'] == tOut['x']*tOut['x']).all()