From e10545506d29e85eed982bc1116d12e0157dff1b Mon Sep 17 00:00:00 2001 From: Hugo Trippaers Date: Fri, 14 Nov 2014 16:00:24 +0100 Subject: [PATCH] Add boilerplates for module unittests --- systemvm/test/python/TestCsApp.py | 21 +++++++++++++++++++++ systemvm/test/python/TestCsConfig.py | 16 ++++++++++++++++ systemvm/test/python/TestCsDatabag.py | 16 ++++++++++++++++ systemvm/test/python/TestCsDhcp.py | 20 ++++++++++++++++++++ systemvm/test/python/TestCsFile.py | 16 ++++++++++++++++ systemvm/test/python/TestCsGuestNetwork.py | 16 ++++++++++++++++ systemvm/test/python/TestCsHelper.py | 18 ++++++++++++++++++ systemvm/test/python/TestCsNetfilter.py | 16 ++++++++++++++++ systemvm/test/python/TestCsProcess.py | 16 ++++++++++++++++ systemvm/test/python/TestCsRedundant.py | 20 ++++++++++++++++++++ systemvm/test/python/TestCsRoute.py | 16 ++++++++++++++++ systemvm/test/python/TestCsRule.py | 16 ++++++++++++++++ 12 files changed, 207 insertions(+) create mode 100644 systemvm/test/python/TestCsApp.py create mode 100644 systemvm/test/python/TestCsConfig.py create mode 100644 systemvm/test/python/TestCsDatabag.py create mode 100644 systemvm/test/python/TestCsDhcp.py create mode 100644 systemvm/test/python/TestCsFile.py create mode 100644 systemvm/test/python/TestCsGuestNetwork.py create mode 100644 systemvm/test/python/TestCsHelper.py create mode 100644 systemvm/test/python/TestCsNetfilter.py create mode 100644 systemvm/test/python/TestCsProcess.py create mode 100644 systemvm/test/python/TestCsRedundant.py create mode 100644 systemvm/test/python/TestCsRoute.py create mode 100644 systemvm/test/python/TestCsRule.py diff --git a/systemvm/test/python/TestCsApp.py b/systemvm/test/python/TestCsApp.py new file mode 100644 index 00000000000..0c982e87c48 --- /dev/null +++ b/systemvm/test/python/TestCsApp.py @@ -0,0 +1,21 @@ +import unittest +from cs.CsApp import CsApp +from cs.CsAddress import CsIP +from cs.CsConfig import CsConfig +import merge + + +class TestCsApp(unittest.TestCase): + + def setUp(self): + merge.dataBag.DPATH = "." + + def test_init(self): + csconfig = CsConfig() + csconfig.set_cl() + csip = CsIP("eth0", csconfig); + csapp = CsApp(csip) + self.assertTrue(csapp is not None) + +if __name__ == '__main__': + unittest.main() diff --git a/systemvm/test/python/TestCsConfig.py b/systemvm/test/python/TestCsConfig.py new file mode 100644 index 00000000000..0ec5e364e05 --- /dev/null +++ b/systemvm/test/python/TestCsConfig.py @@ -0,0 +1,16 @@ +import unittest +from cs.CsConfig import CsConfig +import merge + + +class TestCsConfig(unittest.TestCase): + + def setUp(self): + merge.dataBag.DPATH = "." + + def test_ini(self): + csconfig = CsConfig(False) + self.assertTrue(csconfig is not None) + +if __name__ == '__main__': + unittest.main() diff --git a/systemvm/test/python/TestCsDatabag.py b/systemvm/test/python/TestCsDatabag.py new file mode 100644 index 00000000000..2135367e83a --- /dev/null +++ b/systemvm/test/python/TestCsDatabag.py @@ -0,0 +1,16 @@ +import unittest +from cs.CsDatabag import CsDataBag +import merge + + +class TestCsDatabag(unittest.TestCase): + + def setUp(self): + merge.dataBag.DPATH = "." + + def test_init(self): + csdatabag = CsDataBag("koffie") + self.assertTrue(csdatabag is not None) + +if __name__ == '__main__': + unittest.main() diff --git a/systemvm/test/python/TestCsDhcp.py b/systemvm/test/python/TestCsDhcp.py new file mode 100644 index 00000000000..572c90dd2a3 --- /dev/null +++ b/systemvm/test/python/TestCsDhcp.py @@ -0,0 +1,20 @@ +import unittest +import mock +from cs.CsDhcp import CsDhcp +from cs import CsHelper +import merge + + +class TestCsDhcp(unittest.TestCase): + + def setUp(self): + merge.dataBag.DPATH = "." + + @mock.patch('cs.CsDhcp.CsHelper') + @mock.patch('cs.CsDhcp.CsDnsMasq') + def test_init(self, mock_cshelper, mock_dnsmasq): + csdhcp = CsDhcp({}, None) + self.assertTrue(csdhcp is not None) + +if __name__ == '__main__': + unittest.main() diff --git a/systemvm/test/python/TestCsFile.py b/systemvm/test/python/TestCsFile.py new file mode 100644 index 00000000000..83e4eff6660 --- /dev/null +++ b/systemvm/test/python/TestCsFile.py @@ -0,0 +1,16 @@ +import unittest +from cs.CsFile import CsFile +import merge + + +class TestCsFile(unittest.TestCase): + + def setUp(self): + merge.dataBag.DPATH = "." + + def test_init(self): + csfile = CsFile("testfile") + self.assertTrue(csfile is not None) + +if __name__ == '__main__': + unittest.main() diff --git a/systemvm/test/python/TestCsGuestNetwork.py b/systemvm/test/python/TestCsGuestNetwork.py new file mode 100644 index 00000000000..8a0982e32a1 --- /dev/null +++ b/systemvm/test/python/TestCsGuestNetwork.py @@ -0,0 +1,16 @@ +import unittest +from cs.CsGuestNetwork import CsGuestNetwork +import merge + + +class TestCsGuestNetwork(unittest.TestCase): + + def setUp(self): + merge.dataBag.DPATH = "." + + def test_init(self): + csguestnetwork = CsGuestNetwork({}) + self.assertTrue(csguestnetwork is not None) + +if __name__ == '__main__': + unittest.main() diff --git a/systemvm/test/python/TestCsHelper.py b/systemvm/test/python/TestCsHelper.py new file mode 100644 index 00000000000..346a0dce46e --- /dev/null +++ b/systemvm/test/python/TestCsHelper.py @@ -0,0 +1,18 @@ +import unittest +import mock +from cs import CsHelper +import merge + + +class TestCsHelper(unittest.TestCase): + + def setUp(self): + merge.dataBag.DPATH = "." + + @mock.patch('cs.CsHelper.subprocess') + def test_execute(self, mock_subprocess): + result = CsHelper.execute("/bin/false") + self.assertTrue(result is not None) + +if __name__ == '__main__': + unittest.main() diff --git a/systemvm/test/python/TestCsNetfilter.py b/systemvm/test/python/TestCsNetfilter.py new file mode 100644 index 00000000000..63d63905262 --- /dev/null +++ b/systemvm/test/python/TestCsNetfilter.py @@ -0,0 +1,16 @@ +import unittest +from cs.CsNetfilter import CsNetfilter +import merge + + +class TestCsNetfilter(unittest.TestCase): + + def setUp(self): + merge.dataBag.DPATH = "." + + def test_init(self): + csnetfilter = CsNetfilter() + self.assertTrue(csnetfilter is not None) + +if __name__ == '__main__': + unittest.main() diff --git a/systemvm/test/python/TestCsProcess.py b/systemvm/test/python/TestCsProcess.py new file mode 100644 index 00000000000..d236f443b9d --- /dev/null +++ b/systemvm/test/python/TestCsProcess.py @@ -0,0 +1,16 @@ +import unittest +from cs.CsProcess import CsProcess +import merge + + +class TestCsProcess(unittest.TestCase): + + def setUp(self): + merge.dataBag.DPATH = "." + + def test_init(self): + csprocess = CsProcess({}) + self.assertTrue(csprocess is not None) + +if __name__ == '__main__': + unittest.main() diff --git a/systemvm/test/python/TestCsRedundant.py b/systemvm/test/python/TestCsRedundant.py new file mode 100644 index 00000000000..f5ec1b19a8f --- /dev/null +++ b/systemvm/test/python/TestCsRedundant.py @@ -0,0 +1,20 @@ +import unittest +from cs.CsRedundant import CsRedundant +from cs.CsConfig import CsConfig +import merge + + +class TestCsRedundant(unittest.TestCase): + + def setUp(self): + merge.dataBag.DPATH = "." + + def test_init(self): + csconfig = CsConfig() + csconfig.set_cl() + + csredundant = CsRedundant(csconfig, "address") + self.assertTrue(csredundant is not None) + +if __name__ == '__main__': + unittest.main() diff --git a/systemvm/test/python/TestCsRoute.py b/systemvm/test/python/TestCsRoute.py new file mode 100644 index 00000000000..4c65129456b --- /dev/null +++ b/systemvm/test/python/TestCsRoute.py @@ -0,0 +1,16 @@ +import unittest +from cs.CsRoute import CsRoute +import merge + + +class TestCsRoute(unittest.TestCase): + + def setUp(self): + merge.dataBag.DPATH = "." + + def test_init(self): + csroute = CsRoute(["one","two","three","four"]) + self.assertTrue(csroute is not None) + +if __name__ == '__main__': + unittest.main() diff --git a/systemvm/test/python/TestCsRule.py b/systemvm/test/python/TestCsRule.py new file mode 100644 index 00000000000..e6a22fa5269 --- /dev/null +++ b/systemvm/test/python/TestCsRule.py @@ -0,0 +1,16 @@ +import unittest +from cs.CsRule import CsRule +import merge + + +class TestCsRule(unittest.TestCase): + + def setUp(self): + merge.dataBag.DPATH = "." + + def test_init(self): + csrule = CsRule(["one", "two", "three", "four"]) + self.assertTrue(csrule is not None) + +if __name__ == '__main__': + unittest.main()