Revision af99afa6 test/ganeti.utils_unittest.py
b/test/ganeti.utils_unittest.py | ||
---|---|---|
32 | 32 |
import socket |
33 | 33 |
import shutil |
34 | 34 |
import re |
35 |
import tempfile |
|
35 | 36 |
|
36 | 37 |
import ganeti |
37 | 38 |
import testutils |
... | ... | |
98 | 99 |
self.assert_(not IsProcessAlive(self.pid_non_existing), |
99 | 100 |
"noexisting process detected") |
100 | 101 |
|
102 |
class TestPidFileFunctions(unittest.TestCase): |
|
103 |
"""Tests for WritePidFile, RemovePidFile and IsPidFileAlive""" |
|
104 |
|
|
105 |
def setUp(self): |
|
106 |
self.dir = tempfile.mkdtemp() |
|
107 |
self.f_dpn = lambda name: os.path.join(self.dir, "%s.pid" % name) |
|
108 |
utils._DaemonPidFileName = self.f_dpn |
|
109 |
|
|
110 |
def testPidFileFunctions(self): |
|
111 |
utils.WritePidFile('test') |
|
112 |
self.assert_(os.path.exists(self.f_dpn('test'))) |
|
113 |
self.assert_(utils.IsPidFileAlive(self.f_dpn('test'))) |
|
114 |
utils.RemovePidFile('test') |
|
115 |
self.assert_(not os.path.exists(self.f_dpn('test'))) |
|
116 |
|
|
117 |
def tearDown(self): |
|
118 |
os.rmdir(self.dir) |
|
119 |
|
|
101 | 120 |
|
102 | 121 |
class TestRunCmd(unittest.TestCase): |
103 | 122 |
"""Testing case for the RunCmd function""" |
Also available in: Unified diff