'Update IdP\'s mutable parameters.'

def test_update_idp_mutable_attributes(self):

    default_resp = self._create_default_idp()
    default_idp = self._fetch_attribute_from_response(default_resp, 'identity_provider')
    idp_id = default_idp.get('id')
    url = self.base_url(suffix=idp_id)
    self.assertIsNotNone(idp_id)
    _enabled = (not default_idp.get('enabled'))
    body = {'remote_ids': [uuid.uuid4().hex, uuid.uuid4().hex], 'description': uuid.uuid4().hex, 'enabled': _enabled}
    body = {'identity_provider': body}
    resp = self.patch(url, body=body)
    updated_idp = self._fetch_attribute_from_response(resp, 'identity_provider')
    body = body['identity_provider']
    for key in body.keys():
        if isinstance(body[key], list):
            self.assertEqual(sorted(body[key]), sorted(updated_idp.get(key)))
        else:
            self.assertEqual(body[key], updated_idp.get(key))
    resp = self.get(url)
    updated_idp = self._fetch_attribute_from_response(resp, 'identity_provider')
    for key in body.keys():
        if isinstance(body[key], list):
            self.assertEqual(sorted(body[key]), sorted(updated_idp.get(key)))
        else:
            self.assertEqual(body[key], updated_idp.get(key))
