summaryrefslogtreecommitdiffstats
path: root/src/service-dbus
diff options
context:
space:
mode:
authorRadek Novacek <rnovacek@redhat.com>2013-10-31 11:59:05 +0100
committerRadek Novacek <rnovacek@redhat.com>2013-10-31 11:59:05 +0100
commit683a3a0126109a6aed9dcce3b866231116007d6a (patch)
tree106c39d8665e74f9681b4bf975e44199d0c7b8e0 /src/service-dbus
parent6b245bf1cef3731ef62dd33a1bbcd56922dec16b (diff)
downloadopenlmi-providers-683a3a0126109a6aed9dcce3b866231116007d6a.tar.gz
openlmi-providers-683a3a0126109a6aed9dcce3b866231116007d6a.tar.xz
openlmi-providers-683a3a0126109a6aed9dcce3b866231116007d6a.zip
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.
Diffstat (limited to 'src/service-dbus')
-rw-r--r--src/service-dbus/test/testService.py8
1 files changed, 7 insertions, 1 deletions
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):