Skip to content

Commit

Permalink
config_files_test folder added with 4 testcases
Browse files Browse the repository at this point in the history
  • Loading branch information
ashariff-11 committed Oct 31, 2024
1 parent f0dfae9 commit 77ad094
Show file tree
Hide file tree
Showing 4 changed files with 140 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -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()
Original file line number Diff line number Diff line change
@@ -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()
Original file line number Diff line number Diff line change
@@ -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()
Original file line number Diff line number Diff line change
@@ -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()

0 comments on commit 77ad094

Please sign in to comment.