示例#1
0
 def test_bad_request(self):
     self.assertEqual(
         handle_response(
             {
                 self.CONFIGS['RESPONSE']: 400,
                 self.CONFIGS['ERROR']: 'Bad Request'
             }, self.CONFIGS), '400 : Bad Request')
示例#2
0
 def retrieve(self, group_id):
     """
     Retrieve a group by id.
     Response will be JSON dictionary.
     Raises an exception if HTTP 200 not received.
     """
     path = 'groups/%s' % group_id
     r = self._get(path)
     return handle_response(r)
示例#3
0
 def delete(self, group_id):
     """
     Delete group with given id from Puppet DB.
     Response will be empty string.
     Raises an exception if HTTP 200 not received.
     """
     path = 'groups/%s' % group_id
     r = self._delete(path)
     return handle_response(r)
示例#4
0
 def delete(self, group_id):
     """
     Delete group with given id from Puppet DB.
     Response will be empty string.
     Raises an exception if HTTP 200 not received.
     """
     path = 'groups/%s' % group_id
     r = self._delete(path)
     return handle_response(r)
示例#5
0
 def retrieve(self, group_id):
     """
     Retrieve a group by id.
     Response will be JSON dictionary.
     Raises an exception if HTTP 200 not received.
     """
     path = 'groups/%s' % group_id
     r = self._get(path)
     return handle_response(r)
示例#6
0
 def create(self, group):
     """
     Create new group in Puppet DB from Group object JSON.
     Response will be JSON dictionary.
     Raises an exception if HTTP 200 not received.
     """
     path = 'groups'
     body = group.to_json()
     r = self._post(path, body)
     return handle_response(r)
示例#7
0
 def validate(self, group):
     """
     Validate Group object JSON without creating object in Puppet DB.
     Response will be JSON dictionary.
     Raises an exception if HTTP 200 not received.
     """
     path = 'validate/group'
     body = group.to_json()
     r = self._post(path, body)
     return handle_response(r)
示例#8
0
 def create(self, group):
     """
     Create new group in Puppet DB from Group object JSON.
     Response will be JSON dictionary.
     Raises an exception if HTTP 200 not received.
     """
     path = 'groups'
     body = group.to_json()
     r = self._post(path, body)
     return handle_response(r)
示例#9
0
 def validate(self, group):
     """
     Validate Group object JSON without creating object in Puppet DB.
     Response will be JSON dictionary.
     Raises an exception if HTTP 200 not received.
     """
     path = 'validate/group'
     body = group.to_json()
     r = self._post(path, body)
     return handle_response(r)
示例#10
0
 def update(self, group_delta, group_id):
     """
     Update group with given id in Puppet DB from differences in Group object JSON.
     Response will be JSON dictionary.
     Raises an exception if HTTP 200 not received.
     """
     path = 'groups/%s' % group_id
     if group_delta.has_key('rule'):
         del group_delta['rule']
     body = json.dumps(group_delta)
     r = self._post(path, body)
     return handle_response(r)
示例#11
0
 def retrieve_all(self, inherited=False):
     """
     Retrieve a all groups. Set inherited to True to retrieve all inherited classes in each group.
     Response will be a list of JSON dictionaries.
     Raises an exception if HTTP 200 not received.
     """
     path = 'groups'
     params = None
     if inherited:
         params = {'inherited': True}
     r = self._get(path, params)
     return handle_response(r)
示例#12
0
 def update(self, group_delta, group_id):
     """
     Update group with given id in Puppet DB from differences in Group object JSON.
     Response will be JSON dictionary.
     Raises an exception if HTTP 200 not received.
     """
     path = 'groups/%s' % group_id
     if group_delta.has_key('rule'):
         del group_delta['rule']
     body = json.dumps(group_delta)
     r = self._post(path, body)
     return handle_response(r)
示例#13
0
 def retrieve_all(self, inherited=False):
     """
     Retrieve a all groups. Set inherited to True to retrieve all inherited classes in each group.
     Response will be a list of JSON dictionaries.
     Raises an exception if HTTP 200 not received.
     """
     path = 'groups'
     params = None
     if inherited:
         params = { 'inherited': True }
     r = self._get(path, params)
     return handle_response(r)
示例#14
0
 def test_correct_answer(self):
     self.assertEqual(
         handle_response({self.CONFIGS['RESPONSE']: 200}, self.CONFIGS),
         '200: OK')