示例#1
0
 def getcontact(self):
     for cs in self.webservice.call_clapi(
             'getcontact',
             self.__clapi_action,
             self.name)['result']:
         c_obj = Contact(cs)
         self.contacts[c_obj.name] = c_obj
     return self.contacts
示例#2
0
 def getcontact(self):
     """
     :return: state (True/False), contacts or error message
     """
     state, cs = self.webservice.call_clapi('getcontact',
                                            self.__clapi_action, self.name)
     if state:
         if len(cs['result']) > 0:
             for c in cs['result']:
                 c_obj = Contact(c)
                 self.contacts[c_obj.name] = c_obj
             return state, self.contacts
         else:
             return state, None
     else:
         return state, cs
示例#3
0
    def test_host_deletecontact(self, host_load_data):
        host = host_load_data
        with open(resource_dir / 'test_host_contact.json') as c:
            cs = Contact(json.load(c))

        data = dict()
        data['action'] = 'delcontact'
        data['object'] = 'HOST'
        data['values'] = ["mail-uranus-frontend", "g15x"]

        with patch('requests.post') as patched_post:
            host.deletecontact(cs)
            patched_post.assert_called_with(self.clapi_url,
                                            headers=self.headers,
                                            data=json.dumps(data),
                                            verify=True)