Exemple #1
0
def test_anno_image_input_aws_lambda_event_bad_content_type(
        img_file, json_file):
    test_anno_image_input = AnnotatedImageInput()

    multipart_data, headers = generate_multipart_body(img_file, json_file)
    headers['Content-Type'] = 'image/jpeg'

    aws_lambda_event = {"body": multipart_data, "headers": headers}

    with pytest.raises(BadInput) as e:
        test_anno_image_input.handle_aws_lambda_event(aws_lambda_event,
                                                      predict_image_and_json)

    assert "only supports multipart/form-data" in str(e.value)
Exemple #2
0
def test_anno_image_input_aws_lambda_event(img_file, json_file):
    test_anno_image_input = AnnotatedImageInput()

    multipart_data, headers = generate_multipart_body(img_file, json_file)

    aws_lambda_event = {"body": multipart_data, "headers": headers}
    aws_result = test_anno_image_input.handle_aws_lambda_event(
        aws_lambda_event, predict_image_and_json)

    assert aws_result["statusCode"] == 200
    assert aws_result["body"] == '[[10, 10, 3], "kaith"]'