From 7622d0614b7a63b6d1230cbdff499d10090694ee Mon Sep 17 00:00:00 2001 From: yh202109 Date: Sat, 27 Jul 2024 21:00:55 -0400 Subject: [PATCH] v0.2.21 --- tests/test_cdt.py | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/tests/test_cdt.py b/tests/test_cdt.py index 7c11c7d0..bceee9db 100644 --- a/tests/test_cdt.py +++ b/tests/test_cdt.py @@ -3,7 +3,7 @@ import unittest import pandas as pd -from mtbp3.util.cdt import diff_2cols_in_1df, diff_2cols_in_2df +from mtbp3.util import cdt class TestCdt(unittest.TestCase): def setUp(self): @@ -13,47 +13,45 @@ def setUp(self): def test_diff_2cols_in_1df_with_difference(self): expected_output = pd.DataFrame({'ARM': [3], 'ACTARM': [5], 'diff': ['True']}) - result = diff_2cols_in_1df(self.df) + result = cdt.diff_2cols_in_1df(self.df) self.assertTrue(isinstance(result, pd.DataFrame)) self.assertEqual(len(result), len(self.df)) def test_diff_2cols_in_1df_without_difference(self): tmpdf = self.df[['ARM', 'ARM']] tmpdf.columns = ['ARM', 'ACTARM'] - result = diff_2cols_in_1df(tmpdf) + result = cdt.diff_2cols_in_1df(tmpdf) self.assertTrue(result.empty) def test_diff_2cols_in_1df_invalid_input(self): expected_output = "Input is not a DataFrame." - result = diff_2cols_in_1df("not a dataframe") + result = cdt.diff_2cols_in_1df("not a dataframe") self.assertEqual(result, expected_output) def test_diff_2cols_in_1df_missing_column(self): expected_output = "Column 'COL' does not exist in the DataFrame." - result = diff_2cols_in_1df(self.df, col1='COL') + result = cdt.diff_2cols_in_1df(self.df, col1='COL') self.assertEqual(result, expected_output) def test_diff_2cols_in_2df_with_existing_column(self): expected_output = pd.DataFrame({'gp_1': ['1', '3'], 'gp_2': ['1', '3'], 'source_1': ['True', 'True'], 'source_2': ['True', 'True'], 'count': [1, 2]}) - result = diff_2cols_in_2df(self.df1, self.df2, 'col', 'gp') + result = cdt.diff_2cols_in_2df(self.df1, self.df2, 'col', 'gp') self.assertTrue(isinstance(result, pd.DataFrame)) - # self.assertEqual(result.to_dict(), expected_output.to_dict()) def test_diff_2cols_in_2df_with_non_existing_column(self): expected_output = "Column 'non_existing_col' not found in both dataframes." - result = diff_2cols_in_2df(self.df1, self.df2, 'non_existing_col', 'gp') + result = cdt.diff_2cols_in_2df(self.df1, self.df2, 'non_existing_col', 'gp') self.assertEqual(result, expected_output) def test_diff_2cols_in_2df_with_non_existing_group(self): expected_output = "Group 'non_existing_gp' not found in both dataframes." - result = diff_2cols_in_2df(self.df1, self.df2, 'col', 'non_existing_gp') + result = cdt.diff_2cols_in_2df(self.df1, self.df2, 'col', 'non_existing_gp') self.assertEqual(result, expected_output) def test_diff_2cols_in_2df_with_same_group_and_column(self): expected_output = "Columns 'gp' and 'col' should be different columns." - result = diff_2cols_in_2df(self.df1, self.df2, 'gp', 'gp') + result = cdt.diff_2cols_in_2df(self.df1, self.df2, 'gp', 'gp') self.assertEqual(result, expected_output) - if __name__ == "__main__": unittest.main() \ No newline at end of file