From 683a3a0126109a6aed9dcce3b866231116007d6a Mon Sep 17 00:00:00 2001 From: Radek Novacek Date: Thu, 31 Oct 2013 11:59:05 +0100 Subject: test: fix service tests lmishell no longer automatically refresh the instance after calling some method on it. refresh() must be called manually. Also fix path to the failing.service file when running the test script directly. --- src/service-dbus/test/testService.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/service-dbus/test/testService.py b/src/service-dbus/test/testService.py index 346ca92..77f588b 100644 --- a/src/service-dbus/test/testService.py +++ b/src/service-dbus/test/testService.py @@ -123,6 +123,7 @@ class TestServiceProvider(unittest.TestCase): # Try to start up the service and check it's running service_status_stored = service.Started service.StartService() + service.refresh() self.assertTrue(service.Started, "Service is not started") service_status_ret = subprocess.call("service cups status".split(), stdout=DEV_NULL, stderr=DEV_NULL) @@ -134,6 +135,7 @@ class TestServiceProvider(unittest.TestCase): # Try to stop the service and check it's stopped service_status_stored = service.Started service.StopService() + service.refresh() service_status_ret = subprocess.call("service cups status".split()) self.assertFalse(service.Started) @@ -161,6 +163,7 @@ class TestServiceProvider(unittest.TestCase): # Try to start up the service by using RestartService() service = self.conn.root.cimv2.LMI_Service.first_instance({"Name": "cups.service"}) service.RestartService() + service.refresh() self.assertTrue(service.Started, "Service couldn't be started BACK after RestartService() [OpenLMI]") # Check that pid of the service has changed - service was really @@ -251,6 +254,7 @@ class TestServiceProvider(unittest.TestCase): servicecups = self.conn.root.cimv2.LMI_Service.first_instance({"Name": "cups.service"}) self.assertNotEqual(servicecups, None) servicecups.RestartService() + servicecups.refresh() self.assertTrue (servicecups.Started) @unittest.skip("This tests breaks Pegasus.") @@ -395,6 +399,7 @@ class TestServiceProvider(unittest.TestCase): # and service is still running service = self.conn.root.cimv2.LMI_Service.first_instance({"Name": "cups.service"}) service.StartService() + service.refresh() service.TurnServiceOff() disabled = subprocess.call(["systemctl", "is-enabled", "cups.service"], stdout=DEV_NULL, stderr=DEV_NULL) @@ -411,6 +416,7 @@ class TestServiceProvider(unittest.TestCase): # and service is still not running service.StopService() service.TurnServiceOn() + service.refresh() disabled = subprocess.call(["systemctl", "is-enabled", "cups.service"], stdout=DEV_NULL, stderr=DEV_NULL) self.assertEqual(disabled, 0, @@ -436,7 +442,7 @@ class TestServiceProviderFailingService(unittest.TestCase): """ self.conn = lmishell.connect(HOST, USER, PASSWD) self.assertTrue(isinstance(self.conn, lmishell.LMIConnection), "Couldn't connect to remote provider") - shutil.copy2(os.path.dirname(__file__) + "/failing.service", "/etc/systemd/system/failing.service") + shutil.copy2(os.path.dirname(os.path.abspath(__file__)) + "/failing.service", "/etc/systemd/system/failing.service") subprocess.call ("systemctl daemon-reload".split()) def tearDown(self): -- cgit