def call_action_api(app, action, apikey=None, status=200, **kwargs):
 params = json.dumps(kwargs)
 response = app.post('/api/action/{0}'.format(action), params=params, extra_environ={'Authorization': str(apikey)}, status=status)
 assert ('/api/3/action/help_show?name={0}'.format(action) in response.json['help'])
 if (status in (200,)):
  assert (response.json['success'] is True)
  return response.json['result']
 else:
  assert (response.json['success'] is False)
  return response.json['error']

def call_action_api ( app , action , apikey = None , status = 200 , ** kwargs ) : params = json . dumps ( kwargs ) response = app . post ( '/api/action/{0}' . format ( action ) , params = params , extra_environ = { 'Authorization' : str ( apikey ) } , status = status ) assert ( '/api/3/action/help_show?name={0}' . format ( action ) in response . json [ 'help' ] ) if ( status in ( 200 , ) ) : assert ( response . json [ 'success' ] is True ) return response . json [ 'result' ] else : assert ( response . json [ 'success' ] is False ) return response . json [ 'error' ]
post an http request to the ckan api and return the result .