From 77ad094130c6d0b9084d803c22bbe3ee46a02039 Mon Sep 17 00:00:00 2001 From: Arifulla Shariff <166038015+ashariff-11@users.noreply.github.com> Date: Thu, 31 Oct 2024 15:40:01 +0100 Subject: [PATCH] config_files_test folder added with 4 testcases --- .../monitoring_config_test.py | 37 +++++++++++++++++++ .../config_files_test/service_config_test.py | 33 +++++++++++++++++ .../config_files_test/time_config_test.py | 37 +++++++++++++++++++ .../user_arguments_config_test.py | 33 +++++++++++++++++ 4 files changed, 140 insertions(+) create mode 100644 lang/python/nanobind_core/tests/config_files_test/monitoring_config_test.py create mode 100644 lang/python/nanobind_core/tests/config_files_test/service_config_test.py create mode 100644 lang/python/nanobind_core/tests/config_files_test/time_config_test.py create mode 100644 lang/python/nanobind_core/tests/config_files_test/user_arguments_config_test.py diff --git a/lang/python/nanobind_core/tests/config_files_test/monitoring_config_test.py b/lang/python/nanobind_core/tests/config_files_test/monitoring_config_test.py new file mode 100644 index 0000000000..13dae9f893 --- /dev/null +++ b/lang/python/nanobind_core/tests/config_files_test/monitoring_config_test.py @@ -0,0 +1,37 @@ +import unittest +import nanobind_core as ecal_module + +class TestMonitoringConfiguration(unittest.TestCase): + def setUp(self): + # Create an instance of the Configuration class for each test + self.config = ecal_module.MonitoringConfiguration() + + def test_default_values(self): + # Test that the default values are as expected + self.assertEqual(self.config.filter_excl, "^__.*$") + self.assertEqual(self.config.filter_incl, "") + + def test_modify_values(self): + # Test modifying the attributes + self.config.filter_excl = "new_exclusion_pattern" + self.config.filter_incl = "new_inclusion_pattern" + + # Assert the values have changed as expected + self.assertEqual(self.config.filter_excl, "new_exclusion_pattern") + self.assertEqual(self.config.filter_incl, "new_inclusion_pattern") + + def test_reset_values(self): + # Reset the values and check if they return to default + self.config.filter_excl = "temporary_pattern" + self.config.filter_incl = "another_temporary_pattern" + + # Resetting attributes + self.config.filter_excl = "^__.*$" + self.config.filter_incl = "" + + # Assert the values have reset to default + self.assertEqual(self.config.filter_excl, "^__.*$") + self.assertEqual(self.config.filter_incl, "") + +if __name__ == '__main__': + unittest.main() diff --git a/lang/python/nanobind_core/tests/config_files_test/service_config_test.py b/lang/python/nanobind_core/tests/config_files_test/service_config_test.py new file mode 100644 index 0000000000..35a43d02ab --- /dev/null +++ b/lang/python/nanobind_core/tests/config_files_test/service_config_test.py @@ -0,0 +1,33 @@ +import unittest +import nanobind_core as ecal_module + +class TestServiceConfiguration(unittest.TestCase): + def setUp(self): + # Create an instance of the ServiceConfiguration class for each test + self.config = ecal_module.ServiceConfiguration() + + def test_default_values(self): + # Test that the default values are as expected + self.assertFalse(self.config.protocol_v0) # protocol_v0 should be False by default + self.assertTrue(self.config.protocol_v1) # protocol_v1 should be True by default + + def test_modify_protocol_v0(self): + # Test modifying protocol_v0 + self.config.protocol_v0 = True + self.assertTrue(self.config.protocol_v0) + + # Reset to default + self.config.protocol_v0 = False + self.assertFalse(self.config.protocol_v0) + + def test_modify_protocol_v1(self): + # Test modifying protocol_v1 + self.config.protocol_v1 = False + self.assertFalse(self.config.protocol_v1) + + # Reset to default + self.config.protocol_v1 = True + self.assertTrue(self.config.protocol_v1) + +if __name__ == '__main__': + unittest.main() diff --git a/lang/python/nanobind_core/tests/config_files_test/time_config_test.py b/lang/python/nanobind_core/tests/config_files_test/time_config_test.py new file mode 100644 index 0000000000..02798c4c52 --- /dev/null +++ b/lang/python/nanobind_core/tests/config_files_test/time_config_test.py @@ -0,0 +1,37 @@ +import unittest +import nanobind_core as ecal_module + +class TestConfiguration(unittest.TestCase): + def setUp(self): + # Create an instance of the Configuration class for each test + self.config = ecal_module.TimeConfiguration() + + def test_default_values(self): + # Test that the default values are as expected + self.assertEqual(self.config.timesync_module_rt, "ecaltime-localtime") + self.assertEqual(self.config.timesync_module_replay, "") + + def test_modify_values(self): + # Test modifying the attributes + self.config.timesync_module_rt = "ecaltime-linuxptp" + self.config.timesync_module_replay = "replay-module" + + # Assert the values have changed as expected + self.assertEqual(self.config.timesync_module_rt, "ecaltime-linuxptp") + self.assertEqual(self.config.timesync_module_replay, "replay-module") + + def test_reset_values(self): + # Reset the values and check if they return to default + self.config.timesync_module_rt = "new-module" + self.config.timesync_module_replay = "another-module" + + # Resetting attributes + self.config.timesync_module_rt = "ecaltime-localtime" + self.config.timesync_module_replay = "" + + # Assert the values have reset to default + self.assertEqual(self.config.timesync_module_rt, "ecaltime-localtime") + self.assertEqual(self.config.timesync_module_replay, "") + +if __name__ == '__main__': + unittest.main() diff --git a/lang/python/nanobind_core/tests/config_files_test/user_arguments_config_test.py b/lang/python/nanobind_core/tests/config_files_test/user_arguments_config_test.py new file mode 100644 index 0000000000..7ba1d85ed0 --- /dev/null +++ b/lang/python/nanobind_core/tests/config_files_test/user_arguments_config_test.py @@ -0,0 +1,33 @@ +import unittest +import nanobind_core as ecal_module + +class TestCliConfiguration(unittest.TestCase): + def setUp(self): + # Create an instance of the CliConfiguration class for each test + self.config = ecal_module.CliConfiguration() + + def test_default_values(self): + # Check default values for user_yaml and dump_config + self.assertEqual(self.config.user_yaml, "") # Default for user_yaml should be an empty string + self.assertFalse(self.config.dump_config) # Default for dump_config should be False + + def test_modify_user_yaml(self): + # Modify and test user_yaml + self.config.user_yaml = "config.yaml" + self.assertEqual(self.config.user_yaml, "config.yaml") + + # Reset to default and verify + self.config.user_yaml = "" + self.assertEqual(self.config.user_yaml, "") + + def test_modify_dump_config(self): + # Modify and test dump_config + self.config.dump_config = True + self.assertTrue(self.config.dump_config) + + # Reset to default and verify + self.config.dump_config = False + self.assertFalse(self.config.dump_config) + +if __name__ == '__main__': + unittest.main()