예제 #1
0
  def setUp( self ):
    self.mockAM = MagicMock()
    self.agent_m = importlib.import_module( 'DIRAC.ResourceStatusSystem.Agent.EmailAgent' )
    self.agent_m.AgentModule = self.mockAM
    self.agent_m.FileReport = MagicMock()
    self.agent = EmailAgent()
    self.agent.log = gLogger
    self.agent.am_getOption = self.mockAM
    self.agent.log.setLevel( 'DEBUG' )

    self.action_m = importlib.import_module( 'DIRAC.ResourceStatusSystem.PolicySystem.Actions.EmailAction' )
    self.action_m.AgentModule = self.mockAM

    name = "LogStatusAction"
    decisionParams = {'status': 'Banned', 'reason': 'test', 'tokenOwner': None,
                      'active': 'Active', 'name': 'test1.test1.ch', 'element': 'Resource',
                      'elementType': 'StorageElement', 'statusType': 'ReadAccess'}

    enforcementResult = {'Status': 'Banned', 'Reason': 'test ###',
                         'PolicyAction': [('LogStatusAction', 'LogStatusAction'), ('LogPolicyResultAction', 'LogPolicyResultAction')]}

    singlePolicyResults = [{'Status': 'Banned', 'Policy': {'command': ('DowntimeCommand', 'DowntimeCommand'),
                            'name': 'DT_END', 'args': {'hours': 0, 'onlyCache': True}, 'type': 'DTOngoing',
                            'module': 'DowntimePolicy', 'description': 'Ongoing and scheduled down-times'},
                            'Reason': 'test'}, {'Status': 'Active', 'Policy': {'command': None,
                            'name': 'AlwaysActiveForResource', 'args': None, 'type': 'AlwaysActive',
                            'module': 'AlwaysActivePolicy', 'description': 'A Policy that always returns Active'},
                            'Reason': 'AlwaysActive'}]

    self.action = EmailAction(name, decisionParams, enforcementResult, singlePolicyResults)
    self.action.log = gLogger
    self.action.am_getOption = self.mockAM
    self.agent.log.setLevel( 'DEBUG' )

    self.tc_mock = MagicMock()
    self.tm_mock = MagicMock()
예제 #2
0
    },
    'Reason': 'test'
}, {
    'Status': 'Active',
    'Policy': {
        'command': None,
        'name': 'AlwaysActiveForResource',
        'args': None,
        'type': 'AlwaysActive',
        'module': 'AlwaysActivePolicy',
        'description': 'A Policy that always returns Active'
    },
    'Reason': 'AlwaysActive'
}]

action = EmailAction(name, decisionParams, enforcementResult,
                     singlePolicyResults)
action.log = gLogger
action.log.setLevel('DEBUG')
mockAM = MagicMock()
agent_m = importlib.import_module(
    'DIRAC.ResourceStatusSystem.Agent.EmailAgent')
agent_m.AgentModule = mockAM
agent = agent_m.EmailAgent()
agent.am_getOption = mockAM
agent.log = gLogger
agent.log.setLevel('DEBUG')


def test__emailActionAgent():

    rssClient = ResourceStatusClient()