@pytest.mark.api_gw_method_args({'put_method_args': {'httpMethod': 'GET'}, 'put_method_response_args': {'httpMethod': 'GET'}})
@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_get(api_gw_method, lambda_function, es_client):
    '\n    test_item_search_get\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)
    original_url = api_gw_lambda_integrate_deploy(api_client, api, api_resource, lambda_func)
    req = requests.get(original_url)
    assert (req.status_code == 200), req.text
    fcol = json.loads(req.text)
    assert (len(fcol['features']) == 2)
    url = f'{original_url}?collections=CBERS4-MUX'
    req = requests.get(url)
    assert (req.status_code == 200), req.text
    fcol = json.loads(req.text)
    assert (len(fcol['features']) == 1)
    assert (fcol['features'][0]['collection'] == 'CBERS4-MUX')
    url = f'{original_url}?collections=CBERS4-MUX,CBERS4-AWFI'
    req = requests.get(url)
    assert (req.status_code == 200), req.text
    fcol = json.loads(req.text)
    assert (len(fcol['features']) == 2)
    url = f'{original_url}'
    req = requests.get(url)
    assert (req.status_code == 200), req.text
    fcol = json.loads(req.text)
    assert ('links' not in fcol.keys())
    url = f'{original_url}?limit=1'
    req = requests.get(url)
    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.get(next_href)
    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')
    url = f'{original_url}?ids=CBERS_4_MUX_20170528_090_084_L2'
    req = requests.get(url)
    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')
    url = f'{original_url}?'
    url += urlencode({'query': '{"cbers:data_type": {"eq":"L4"}}'})
    req = requests.get(url)
    assert (req.status_code == 200), req.text
    fcol = json.loads(req.text)
    assert (len(fcol['features']) == 1)
    assert (fcol['features'][0]['id'] == 'CBERS_4_AWFI_20170409_167_123_L4')
test_item_search_get
@pytest.mark.api_gw_method_args({'put_method_args': {'httpMethod': 'GET'}, 'put_method_response_args': {'httpMethod': 'GET'}})
@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)
    original_url = api_gw_lambda_integrate_deploy(api_client, api, api_resource, lambda_func)
    req = requests.get(original_url)
    assert (req.status_code == 200), req.text
    fcol = json.loads(req.text)
    assert (len(fcol['features']) == 2)
    url = f'{original_url}?collections=CBERS4-MUX'
    req = requests.get(url)
    assert (req.status_code == 200), req.text
    fcol = json.loads(req.text)
    assert (len(fcol['features']) == 1)
    assert (fcol['features'][0]['collection'] == 'CBERS4-MUX')
    url = f'{original_url}?collections=CBERS4-MUX,CBERS4-AWFI'
    req = requests.get(url)
    assert (req.status_code == 200), req.text
    fcol = json.loads(req.text)
    assert (len(fcol['features']) == 2)
    url = f'{original_url}'
    req = requests.get(url)
    assert (req.status_code == 200), req.text
    fcol = json.loads(req.text)
    assert ('links' not in fcol.keys())
    url = f'{original_url}?limit=1'
    req = requests.get(url)
    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.get(next_href)
    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')
    url = f'{original_url}?ids=CBERS_4_MUX_20170528_090_084_L2'
    req = requests.get(url)
    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')
    url = f'{original_url}?'
    url += urlencode({'query': '{"cbers:data_type": {"eq":"L4"}}'})
    req = requests.get(url)
    assert (req.status_code == 200), req.text
    fcol = json.loads(req.text)
    assert (len(fcol['features']) == 1)
    assert (fcol['features'][0]['id'] == 'CBERS_4_AWFI_20170409_167_123_L4')