@pytest.mark.api_gw_method_args({'put_method_args': {'httpMethod': 'POST'}, 'put_method_response_args': {'httpMethod': 'POST'}})
@pytest.mark.lambda_function_args({'name': 'elasticsearch', 'handler': 'es.stac_search_endpoint_handler', 'environment': {}, 'timeout': 30, 'layers': ({'output_dir': './test', 'layer_dir': './cbers2stac/layers/common', 'tag': 'common'},)})
def test_item_search_post(api_gw_method, lambda_function, es_client):
    '\n    test_item_search_post\n    '
    (api_client, api, api_resource) = api_gw_method
    (lambda_client, lambda_func) = lambda_function
    lambda_client.update_function_configuration(FunctionName=lambda_func['FunctionName'], Environment={'Variables': {'ES_PORT': '4571', 'ES_SSL': 'NO'}})
    populate_es_test_case_1(es_client)
    url = api_gw_lambda_integrate_deploy(api_client, api, api_resource, lambda_func, http_method='POST')
    req = requests.post(url, data=json.dumps({'collections': ['mycollection'], 'bbox': [160.6, (- 55.95), (- 170), (- 25.89)], 'limit': 100, 'datetime': '2019-01-01T00:00:00Z/2019-01-01T23:59:59Z'}))
    assert (req.status_code == 400), req.text
    assert ('First lon corner is not western' in req.text)
    req = requests.post(url, data=json.dumps({'collections': ['mycollection'], 'bbox': [(- 170), (- 25.89), 160.6, (- 55.95)], 'limit': 100, 'datetime': '2019-01-01T00:00:00Z/2019-01-01T23:59:59Z'}))
    assert (req.status_code == 200), req.text
    req = requests.post(url)
    assert (req.status_code == 200), req.text
    fcol = json.loads(req.text)
    assert ('links' not in fcol.keys())
    body = {'limit': 1}
    req = requests.post(url, data=json.dumps(body))
    assert (req.status_code == 200), req.text
    fcol = json.loads(req.text)
    assert ('links' in fcol.keys())
    assert (len(fcol['links']) == 1)
    next_href = to_localstack_url(api['id'], fcol['links'][0]['href'])
    req = requests.post(next_href, data=json.dumps({**body, **fcol['links'][0]['body']}))
    assert (req.status_code == 200), req.text
    fcol = json.loads(req.text)
    assert ('links' not in fcol.keys())
    assert (fcol['features'][0]['id'] == 'CBERS_4_MUX_20170528_090_084_L2')
    body = {'ids': ['CBERS_4_MUX_20170528_090_084_L2']}
    req = requests.post(url, data=json.dumps(body))
    assert (req.status_code == 200), req.text
    fcol = json.loads(req.text)
    assert (len(fcol['features']) == 1)
    assert (fcol['features'][0]['id'] == 'CBERS_4_MUX_20170528_090_084_L2')
test_item_search_post
@pytest.mark.api_gw_method_args({'put_method_args': {'httpMethod': 'POST'}, 'put_method_response_args': {'httpMethod': 'POST'}})
@pytest.mark.lambda_function_args({'name': 'elasticsearch', 'handler': 'es.stac_search_endpoint_handler', 'environment': {}, 'timeout': 30, 'layers': ({'output_dir': './test', 'layer_dir': './cbers2stac/layers/common', 'tag': 'common'},)})
def (api_gw_method, lambda_function, es_client):
    '\n    \n    '
    (api_client, api, api_resource) = api_gw_method
    (lambda_client, lambda_func) = lambda_function
    lambda_client.update_function_configuration(FunctionName=lambda_func['FunctionName'], Environment={'Variables': {'ES_PORT': '4571', 'ES_SSL': 'NO'}})
    populate_es_test_case_1(es_client)
    url = api_gw_lambda_integrate_deploy(api_client, api, api_resource, lambda_func, http_method='POST')
    req = requests.post(url, data=json.dumps({'collections': ['mycollection'], 'bbox': [160.6, (- 55.95), (- 170), (- 25.89)], 'limit': 100, 'datetime': '2019-01-01T00:00:00Z/2019-01-01T23:59:59Z'}))
    assert (req.status_code == 400), req.text
    assert ('First lon corner is not western' in req.text)
    req = requests.post(url, data=json.dumps({'collections': ['mycollection'], 'bbox': [(- 170), (- 25.89), 160.6, (- 55.95)], 'limit': 100, 'datetime': '2019-01-01T00:00:00Z/2019-01-01T23:59:59Z'}))
    assert (req.status_code == 200), req.text
    req = requests.post(url)
    assert (req.status_code == 200), req.text
    fcol = json.loads(req.text)
    assert ('links' not in fcol.keys())
    body = {'limit': 1}
    req = requests.post(url, data=json.dumps(body))
    assert (req.status_code == 200), req.text
    fcol = json.loads(req.text)
    assert ('links' in fcol.keys())
    assert (len(fcol['links']) == 1)
    next_href = to_localstack_url(api['id'], fcol['links'][0]['href'])
    req = requests.post(next_href, data=json.dumps({**body, **fcol['links'][0]['body']}))
    assert (req.status_code == 200), req.text
    fcol = json.loads(req.text)
    assert ('links' not in fcol.keys())
    assert (fcol['features'][0]['id'] == 'CBERS_4_MUX_20170528_090_084_L2')
    body = {'ids': ['CBERS_4_MUX_20170528_090_084_L2']}
    req = requests.post(url, data=json.dumps(body))
    assert (req.status_code == 200), req.text
    fcol = json.loads(req.text)
    assert (len(fcol['features']) == 1)
    assert (fcol['features'][0]['id'] == 'CBERS_4_MUX_20170528_090_084_L2')