Commit af99afa6 authored by Guido Trotter's avatar Guido Trotter
Browse files

Add utils unittests for new functions

The submitted WritePidFile, RemovePidfile and IsPidFileAlive functions
miss unit tests. Adding a simple one which covers their basic

Reviewed-by: iustinp
parent ce594241
...@@ -32,6 +32,7 @@ import signal ...@@ -32,6 +32,7 @@ import signal
import socket import socket
import shutil import shutil
import re import re
import tempfile
import ganeti import ganeti
import testutils import testutils
...@@ -98,6 +99,24 @@ class TestIsProcessAlive(unittest.TestCase): ...@@ -98,6 +99,24 @@ class TestIsProcessAlive(unittest.TestCase):
self.assert_(not IsProcessAlive(self.pid_non_existing), self.assert_(not IsProcessAlive(self.pid_non_existing),
"noexisting process detected") "noexisting process detected")
class TestPidFileFunctions(unittest.TestCase):
"""Tests for WritePidFile, RemovePidFile and IsPidFileAlive"""
def setUp(self):
self.dir = tempfile.mkdtemp()
self.f_dpn = lambda name: os.path.join(self.dir, "" % name)
utils._DaemonPidFileName = self.f_dpn
def testPidFileFunctions(self):
self.assert_(not os.path.exists(self.f_dpn('test')))
def tearDown(self):
class TestRunCmd(unittest.TestCase): class TestRunCmd(unittest.TestCase):
"""Testing case for the RunCmd function""" """Testing case for the RunCmd function"""
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment