Commit d019f8bd authored by Iustin Pop's avatar Iustin Pop
Browse files

Fix hooks unittests after RPC result changes



Patch "Simplify the RPC result framework in backend.py" changed all
RPCs, and thus the hooks results where also changed. This needs changes
to the hooks unittests too.
Signed-off-by: default avatarIustin Pop <iustin@google.com>
Reviewed-by: default avatarGuido Trotter <ultrotter@google.com>
parent 6f7d4e75
...@@ -75,8 +75,7 @@ class TestHooksRunner(unittest.TestCase): ...@@ -75,8 +75,7 @@ class TestHooksRunner(unittest.TestCase):
def testEmpty(self): def testEmpty(self):
"""Test no hooks""" """Test no hooks"""
for phase in (constants.HOOKS_PHASE_PRE, constants.HOOKS_PHASE_POST): for phase in (constants.HOOKS_PHASE_PRE, constants.HOOKS_PHASE_POST):
self.failUnlessEqual(self.hr.RunHooks(self.hpath, phase, {}), self.failUnlessEqual(self.hr.RunHooks(self.hpath, phase, {}), [])
(True, []))
def testSkipNonExec(self): def testSkipNonExec(self):
"""Test skip non-exec file""" """Test skip non-exec file"""
...@@ -86,7 +85,7 @@ class TestHooksRunner(unittest.TestCase): ...@@ -86,7 +85,7 @@ class TestHooksRunner(unittest.TestCase):
f.close() f.close()
self.torm.append((fname, False)) self.torm.append((fname, False))
self.failUnlessEqual(self.hr.RunHooks(self.hpath, phase, {}), self.failUnlessEqual(self.hr.RunHooks(self.hpath, phase, {}),
(True, [(self._rname(fname), HKR_SKIP, "")])) [(self._rname(fname), HKR_SKIP, "")])
def testSkipInvalidName(self): def testSkipInvalidName(self):
"""Test skip script with invalid name""" """Test skip script with invalid name"""
...@@ -98,7 +97,7 @@ class TestHooksRunner(unittest.TestCase): ...@@ -98,7 +97,7 @@ class TestHooksRunner(unittest.TestCase):
os.chmod(fname, 0700) os.chmod(fname, 0700)
self.torm.append((fname, False)) self.torm.append((fname, False))
self.failUnlessEqual(self.hr.RunHooks(self.hpath, phase, {}), self.failUnlessEqual(self.hr.RunHooks(self.hpath, phase, {}),
(True, [(self._rname(fname), HKR_SKIP, "")])) [(self._rname(fname), HKR_SKIP, "")])
def testSkipDir(self): def testSkipDir(self):
"""Test skip directory""" """Test skip directory"""
...@@ -107,7 +106,7 @@ class TestHooksRunner(unittest.TestCase): ...@@ -107,7 +106,7 @@ class TestHooksRunner(unittest.TestCase):
os.mkdir(fname) os.mkdir(fname)
self.torm.append((fname, True)) self.torm.append((fname, True))
self.failUnlessEqual(self.hr.RunHooks(self.hpath, phase, {}), self.failUnlessEqual(self.hr.RunHooks(self.hpath, phase, {}),
(True, [(self._rname(fname), HKR_SKIP, "")])) [(self._rname(fname), HKR_SKIP, "")])
def testSuccess(self): def testSuccess(self):
"""Test success execution""" """Test success execution"""
...@@ -119,7 +118,7 @@ class TestHooksRunner(unittest.TestCase): ...@@ -119,7 +118,7 @@ class TestHooksRunner(unittest.TestCase):
self.torm.append((fname, False)) self.torm.append((fname, False))
os.chmod(fname, 0700) os.chmod(fname, 0700)
self.failUnlessEqual(self.hr.RunHooks(self.hpath, phase, {}), self.failUnlessEqual(self.hr.RunHooks(self.hpath, phase, {}),
(True, [(self._rname(fname), HKR_SUCCESS, "")])) [(self._rname(fname), HKR_SUCCESS, "")])
def testSymlink(self): def testSymlink(self):
"""Test running a symlink""" """Test running a symlink"""
...@@ -128,7 +127,7 @@ class TestHooksRunner(unittest.TestCase): ...@@ -128,7 +127,7 @@ class TestHooksRunner(unittest.TestCase):
os.symlink("/bin/true", fname) os.symlink("/bin/true", fname)
self.torm.append((fname, False)) self.torm.append((fname, False))
self.failUnlessEqual(self.hr.RunHooks(self.hpath, phase, {}), self.failUnlessEqual(self.hr.RunHooks(self.hpath, phase, {}),
(True, [(self._rname(fname), HKR_SUCCESS, "")])) [(self._rname(fname), HKR_SUCCESS, "")])
def testFail(self): def testFail(self):
"""Test success execution""" """Test success execution"""
...@@ -140,7 +139,7 @@ class TestHooksRunner(unittest.TestCase): ...@@ -140,7 +139,7 @@ class TestHooksRunner(unittest.TestCase):
self.torm.append((fname, False)) self.torm.append((fname, False))
os.chmod(fname, 0700) os.chmod(fname, 0700)
self.failUnlessEqual(self.hr.RunHooks(self.hpath, phase, {}), self.failUnlessEqual(self.hr.RunHooks(self.hpath, phase, {}),
(True, [(self._rname(fname), HKR_FAIL, "")])) [(self._rname(fname), HKR_FAIL, "")])
def testCombined(self): def testCombined(self):
"""Test success, failure and skip all in one test""" """Test success, failure and skip all in one test"""
...@@ -157,8 +156,7 @@ class TestHooksRunner(unittest.TestCase): ...@@ -157,8 +156,7 @@ class TestHooksRunner(unittest.TestCase):
self.torm.append((fname, False)) self.torm.append((fname, False))
os.chmod(fname, 0700) os.chmod(fname, 0700)
expect.append((self._rname(fname), rs, "")) expect.append((self._rname(fname), rs, ""))
self.failUnlessEqual(self.hr.RunHooks(self.hpath, phase, {}), self.failUnlessEqual(self.hr.RunHooks(self.hpath, phase, {}), expect)
(True, expect))
def testOrdering(self): def testOrdering(self):
for phase in (constants.HOOKS_PHASE_PRE, constants.HOOKS_PHASE_POST): for phase in (constants.HOOKS_PHASE_PRE, constants.HOOKS_PHASE_POST):
...@@ -174,8 +172,7 @@ class TestHooksRunner(unittest.TestCase): ...@@ -174,8 +172,7 @@ class TestHooksRunner(unittest.TestCase):
self.torm.append((fname, False)) self.torm.append((fname, False))
expect.append((self._rname(fname), HKR_SUCCESS, "")) expect.append((self._rname(fname), HKR_SUCCESS, ""))
expect.sort() expect.sort()
self.failUnlessEqual(self.hr.RunHooks(self.hpath, phase, {}), self.failUnlessEqual(self.hr.RunHooks(self.hpath, phase, {}), expect)
(True, expect))
def testEnv(self): def testEnv(self):
"""Test environment execution""" """Test environment execution"""
...@@ -187,8 +184,7 @@ class TestHooksRunner(unittest.TestCase): ...@@ -187,8 +184,7 @@ class TestHooksRunner(unittest.TestCase):
env_snt = {"PHASE": phase} env_snt = {"PHASE": phase}
env_exp = "PHASE=%s" % phase env_exp = "PHASE=%s" % phase
self.failUnlessEqual(self.hr.RunHooks(self.hpath, phase, env_snt), self.failUnlessEqual(self.hr.RunHooks(self.hpath, phase, env_snt),
(True, [(self._rname(fname), HKR_SUCCESS, [(self._rname(fname), HKR_SUCCESS, env_exp)])
env_exp)]))
class TestHooksMaster(unittest.TestCase): class TestHooksMaster(unittest.TestCase):
......
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