From 2c75c8544b363fc5dbc4348ee5b16707d6c9343a Mon Sep 17 00:00:00 2001 From: Clgould99 Date: Fri, 7 Jun 2024 13:33:53 -0700 Subject: [PATCH] added unittests to analysis --- alfred/tests/test_analysis.py | 44 ++++++++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/alfred/tests/test_analysis.py b/alfred/tests/test_analysis.py index 66bdf34..37ad2c5 100644 --- a/alfred/tests/test_analysis.py +++ b/alfred/tests/test_analysis.py @@ -41,6 +41,48 @@ def test_count_swapped_modules_output(self): self.assertIn("0 = healthy and 1 = swapped", captured_output_str) def tearDown(self): pass - + + +class TestStandardizeColumns(unittest.TestCase): + def setUp(self): + self.valid_directory = os.path.join(data_path, 'all_buses/') + def test_standardize_columns(self): + df = alfred.count_mod_changes(self.valid_directory) + + result = alfred.standardize_columns(df) + + self.assertIsInstance(result, pd.DataFrame) + + def tearDown(self): + pass + +class TestBuildAllVoltagesDF(unittest.TestCase): + def setUp(self): + self.valid_directory = os.path.join(data_path, 'all_buses/') + + def test_returns_dataframe(self): + result = alfred.build_all_voltages_df(self.valid_directory) + self.assertIsInstance(result, pd.DataFrame, "The function should return a pandas DataFrame") + + def test_includes_bus_column(self): + result = alfred.build_all_voltages_df(self.valid_directory) + self.assertIn('Bus', result.columns, "The DataFrame should include a 'Bus' column") + + def test_includes_module_column(self): + result = alfred.build_all_voltages_df(self.valid_directory) + self.assertIn('Module', result.columns, "The DataFrame should include a 'Module' column") + def tearDown(self): + pass + +class TestMeanCenter(unittest.TestCase): + def setUp(self): + self.valid_directory = os.path.join(data_path, 'all_buses/') + + def test_output_is_tuple_with_three_elements(self): + result = alfred.mean_center(self.valid_directory) + self.assertIsInstance(result, tuple, "The function should return a tuple") + self.assertEqual(len(result), 3, "The tuple should have exactly three elements") + def tearDown(self): + pass if __name__ == '__main__': unittest.main()