Mock support for pathutils
authorHelga Velroyen <helgav@google.com>
Wed, 4 Mar 2015 18:14:28 +0000 (19:14 +0100)
committerHelga Velroyen <helgav@google.com>
Wed, 18 Mar 2015 10:19:42 +0000 (11:19 +0100)
For better LURenewCrypto unit tests, we need to be able to
mock the pathutils module. This makes it necessary to add
some support to the testutils for patching this module.

Signed-off-by: Helga Velroyen <helgav@google.com>
Reviewed-by: Petr Pudlak <pudlak@google.com>

Makefile.am
test/py/cmdlib/testsupport/__init__.py
test/py/cmdlib/testsupport/pathutils_mock.py [copied from test/py/cmdlib/testsupport/ssh_mock.py with 90% similarity]

index bda85d4..a384351 100644 (file)
@@ -1574,6 +1574,7 @@ python_test_support = \
        test/py/cmdlib/testsupport/iallocator_mock.py \
        test/py/cmdlib/testsupport/lock_manager_mock.py \
        test/py/cmdlib/testsupport/netutils_mock.py \
+       test/py/cmdlib/testsupport/pathutils_mock.py \
        test/py/cmdlib/testsupport/processor_mock.py \
        test/py/cmdlib/testsupport/rpc_runner_mock.py \
        test/py/cmdlib/testsupport/ssh_mock.py \
index 38370d3..d121c37 100644 (file)
@@ -40,6 +40,7 @@ from cmdlib.testsupport.utils_mock import patchUtils
 from cmdlib.testsupport.lock_manager_mock import LockManagerMock
 from cmdlib.testsupport.netutils_mock import patchNetutils, HostnameMock
 from cmdlib.testsupport.processor_mock import ProcessorMock
+from cmdlib.testsupport.pathutils_mock import patchPathutils
 from cmdlib.testsupport.rpc_runner_mock import CreateRpcRunnerMock, \
   RpcResultsBuilder
 from cmdlib.testsupport.ssh_mock import patchSsh
@@ -53,6 +54,7 @@ __all__ = ["CmdlibTestCase",
            "patchUtils",
            "patchNetutils",
            "patchSsh",
+           "patchPathutils",
            "LockManagerMock",
            "ProcessorMock",
            "RpcResultsBuilder",
similarity index 90%
copy from test/py/cmdlib/testsupport/ssh_mock.py
copy to test/py/cmdlib/testsupport/pathutils_mock.py
index 5b7268a..9e59dc4 100644 (file)
@@ -1,7 +1,7 @@
 #
 #
 
-# Copyright (C) 2013 Google Inc.
+# Copyright (C) 2015 Google Inc.
 # All rights reserved.
 #
 # Redistribution and use in source and binary forms, with or without
@@ -35,8 +35,8 @@ from cmdlib.testsupport.util import patchModule
 
 
 # pylint: disable=C0103
-def patchSsh(module_under_test):
-  """Patches the L{ganeti.ssh} module for tests.
+def patchPathutils(module_under_test):
+  """Patches the L{ganeti.pathutils} module for tests.
 
   This function is meant to be used as a decorator for test methods.
 
@@ -45,4 +45,4 @@ def patchSsh(module_under_test):
         "ganeti.cmdlib" prefix is optional.
 
   """
-  return patchModule(module_under_test, "ssh")
+  return patchModule(module_under_test, "pathutils")