def setUp(self): parent = interfaceMock(xenrt.interfaces.OSParent) parent._osParent_getPowerState = lambda: xenrt.PowerState.up self.__linux = LinuxOS(None, parent) self.__ssh = Mock() self.__linux.waitForSSH = Mock() self.__linux.execSSH = self.__ssh
def test_instanceInterface(self): """Verify the Instance class implements the OSParent interface""" # Mock out the methods used by the Instance __init__ so they don't get called xenrt.lib.opsys.osFactory = Mock() # Crete the Instance, mocking toolstack i = xenrt.lib.generic.Instance(interfaceMock(xenrt.interfaces.Toolstack), None, None, None, None) # Do the verification verifyObject(xenrt.interfaces.OSParent, i)
def test_instanceInterface(self): """Verify the Instance class implements the OSParent interface""" # Mock out the methods used by the Instance __init__ so they don't get called xenrt.lib.opsys.osFactory = Mock() # Crete the Instance, mocking toolstack i = xenrt.lib.generic.Instance( interfaceMock(xenrt.interfaces.Toolstack), None, None, None, None) # Do the verification verifyObject(xenrt.interfaces.OSParent, i)
def oslib_supportedInstallMethods(oslib): # Instantiate the OS library o = oslib.testInit(interfaceMock(xenrt.interfaces.OSParent)) implementedInterfaces = list(implementedBy(oslib)) # Determine what interfaces are required based on the supportedInstallMethods attribute requiredInterfaces = filter(lambda i: o._allInstallMethods[i] in o.supportedInstallMethods, o._allInstallMethods) # Verify the required interfaces are implemented for i in requiredInterfaces: if not i in implementedInterfaces: raise AssertionError("Interface %s not implemented but stated in supportedInstallMethods" % i.__name__)
def oslib_supportedInstallMethods(oslib): # Instantiate the OS library o = oslib.testInit(interfaceMock(xenrt.interfaces.OSParent)) implementedInterfaces = list(implementedBy(oslib)) # Determine what interfaces are required based on the supportedInstallMethods attribute requiredInterfaces = filter( lambda i: o._allInstallMethods[i] in o.supportedInstallMethods, o._allInstallMethods) # Verify the required interfaces are implemented for i in requiredInterfaces: if not i in implementedInterfaces: raise AssertionError( "Interface %s not implemented but stated in supportedInstallMethods" % i.__name__)
def setUp(self): # Set up a series of method mocks invlved in assertHealthy parent = interfaceMock(xenrt.interfaces.OSParent) parent._osParent_getPowerState = lambda: xenrt.PowerState.up self.__win = WindowsOS(None, parent) self.__randomWord = "SomeRandomStringOrOther" generator = FakeRandomStringGenerator(self.__randomWord) self.__win.randomStringGenerator = generator self.__create = Mock() self.__win.createFile = self.__create self.__read = Mock(return_value=self.__randomWord) self.__win.readFile = self.__read self.__remove = Mock() self.__win.removeFile = self.__remove
def setUp(self): self.parent = interfaceMock(xenrt.interfaces.OSParent)
def oslib_test(oslib): # Instantiate the OS library o = oslib.testInit(interfaceMock(xenrt.interfaces.OSParent)) # Verify all interfaces declared as being implemented for i in list(implementedBy(oslib)): verifyObject(i, o)