def TestEquals(self): actions = [ FailureActionTypeFactory.CreateNoAction(long(1))] resetPeriod = FailureActionConfigurationResetPeriodType(1) rebootMsg = FailureActionConfigurationRebootMessageType('MyRebootMessage') commandLine = FailureActionConfigurationCommandLineType('MyCommandLine') failureActions1 = FailureActionConfigurationType(actions, resetPeriod, rebootMsg, commandLine) failureActions2 = FailureActionConfigurationType(actions, resetPeriod, rebootMsg, commandLine) self.assertEquals(failureActions1, failureActions2)
def GetNewConfig2Params(self): failureActionList = [] failureActionList.append( FailureActionTypeFactory.CreateRestartAction(300)) failureActionList.append( FailureActionTypeFactory.CreateRunCommandAction(0)) rebootMessage = FailureActionConfigurationRebootMessageType( 'rebootMessage') command = FailureActionConfigurationCommandLineType('command') resetPeriod = FailureActionConfigurationResetPeriodType(300) FailureActions = FailureActionConfigurationType( failureActionList, resetPeriod, rebootMessage, command) newServiceDefinition = NewServiceDefinition( serviceName="TestService", displayName="TestService", binaryPathName="C:\\Windows\\System32\\cmd.exe /c echo hello", delayedAutoStartInfo=False, failureFlag=False, preShutdownInfo=long(18000), serviceSIDInfo='SID_TYPE_UNRESTRICTED', description='TestService', failureActions=FailureActions) return newServiceDefinition
def TestInitWithUnBoxedCommandLine(self): actions = [ FailureActionTypeFactory.CreateNoAction(long(1))] resetPeriod = FailureActionConfigurationResetPeriodType(1) rebootMsg = FailureActionConfigurationRebootMessageType('MyRebootMessage') commandLine = 'MyCommandLine' commandLine1 = FailureActionConfigurationCommandLineType('MyCommandLine') config1 = FailureActionConfigurationType(actions, resetPeriod, rebootMsg, commandLine) config2 = FailureActionConfigurationType(actions, resetPeriod, rebootMsg, commandLine1) self.assertEquals(config1.StringValue(), config2.StringValue()) self.assertEquals(config1.Win32Value(), config2.Win32Value())
def TestInitWithListOfFailureActions(self): actions = [ FailureActionTypeFactory.CreateNoAction(long(1))] resetPeriod = FailureActionConfigurationResetPeriodType(1) rebootMsg = FailureActionConfigurationRebootMessageType('MyRebootMessage') commandLine = FailureActionConfigurationCommandLineType('MyCommandLine') failureActions = FailureActionConfigurationType(actions, resetPeriod, rebootMsg, commandLine) t = failureActions.StringValue() self.assertEquals(failureActions.StringValue(), failureActions.StringValue()) self.assertEquals(failureActions.Win32Value(), failureActions.Win32Value())
def TestUpdateFailureActionsConfiguration(self): configs = self.GetNewConfig2Params() service = ServiceConfigurations2.GenerateFromOperatingSystem( -1, configs.ServiceName) service2 = ServiceConfigurations2.GenerateFromOperatingSystem( -1, configs.ServiceName) failureActionList = [] delay = 1000 failureActionList.append( FailureActionTypeFactory.CreateRestartAction(delay)) resetPeriod = 1 rebootMsg = None commandLine = None failureActions = FailureActionConfigurationType( failureActionList, resetPeriod, rebootMsg, commandLine) service.UpdateConfiguration('FailureActions', failureActions) service2.Configurations['FailureActions'] = failureActions self.assertTrue(service, service2)
def TestInitWithParametersNone(self): value = None config1 = FailureActionConfigurationType(value, value, value, value) config2 = FailureActionConfigurationType(value, value, value, value) self.assertEquals(config1.StringValue(), config2.StringValue()) self.assertEquals(config1.Win32Value(), config2.Win32Value())