diff options
author | Eugeniy E. Mikhailov <evgmik@gmail.com> | 2024-06-02 23:05:41 -0400 |
---|---|---|
committer | Eugeniy E. Mikhailov <evgmik@gmail.com> | 2024-06-02 23:05:41 -0400 |
commit | 605238126fe5f99d69b0de3f5278ff83f21349b6 (patch) | |
tree | 6d15d11cb15f14c90f22a48e7e8db7dafbc62c77 /tests | |
parent | d32aaa6bce0eacd5d6ee919a239c7aaad606fc23 (diff) | |
download | qolab-605238126fe5f99d69b0de3f5278ff83f21349b6.tar.gz qolab-605238126fe5f99d69b0de3f5278ff83f21349b6.zip |
more test cases and bugfixes in tableflow
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_tableflow.py | 32 |
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() |