Exemplo n.º 1
0
def test_handler_unknown_method(create_event,
                                patch_get_custom_resources_mapping,
                                patch_requests_put):
    with pytest.raises(exceptions.EventSerializationException):
        create_event['RequestType'] = 'Handstand'
        handler_result = handler.handler(create_event, None)
    assert patch_requests_put.call_count == 0
Exemplo n.º 2
0
def test_handler_extra_request_keys(create_event,
                                    patch_get_custom_resources_mapping,
                                    patch_requests_put):
    create_event['Bingo'] = 'Was his name-o.'
    handler_result = handler.handler(create_event, None)
    assert patch_requests_put.call_count == 1
    assert handler_result['Status'] == 'SUCCESS'
Exemplo n.º 3
0
def test_handler(create_event, patch_get_custom_resources_mapping,
                 patch_requests_put):
    handler_result = handler.handler(create_event, None)
    assert patch_requests_put.call_count == 1
    args, kwargs = patch_requests_put.call_args
    assert handler_result == kwargs['json']
    assert handler_result['Status'] == 'SUCCESS'
Exemplo n.º 4
0
def test_handler_bad_resource_type(create_event,
                                   patch_get_custom_resources_mapping,
                                   patch_requests_put):
    create_event['ResourceType'] = 'Custom::WrongAnswer'
    handler_result = handler.handler(create_event, None)
    assert patch_requests_put.call_count == 1
    assert handler_result['Status'] == 'FAILED'
    assert 'WrongAnswer' in handler_result['Reason']
Exemplo n.º 5
0
def test_handler_put_error(create_event, patch_get_custom_resources_mapping,
                           patch_requests_put):
    patch_requests_put.side_effect = requests.exceptions.ConnectionError()
    with pytest.raises(exceptions.CloudFormationReportingException):
        handler.handler(create_event, None)
    assert patch_requests_put.call_count == 1