def test_post_events_validation_error(metadata_api, mock_auth): post_event_response_1 = handler.post_events( post_event_data.validation_error_event_1, {}) post_event_response_2 = handler.post_events( post_event_data.validation_error_event_2, {}) assert post_event_response_1 == post_event_data.validation_error_response assert post_event_response_2 == post_event_data.validation_error_response
def test_post_events_failed_records(metadata_api, mock_auth, failed_records, mock_stream_name): post_event_response = handler.post_events(post_event_data.event_with_list, {}) expected_response = { "statusCode": 500, "body": '{"message": "Request failed for some elements", "failedElements": [{"key00": "value00"}, {"key10": "value10"}]}', } assert post_event_response == expected_response
def test_post_events_client_error(metadata_api, mock_auth, mock_stream_name): stream_name = "dp.green.dataset-123.incoming.version-123.json" create_event_stream(stream_name) post_event_response = handler.post_events(post_event_data.event_with_list, {}) assert post_event_response == post_event_data.error_response
def test_post_events_metadata_server_error(metadata_api, mock_auth): post_event_response = handler.post_events( post_event_data.event_server_error, {}) assert post_event_response == post_event_data.error_response
def test_post_events_not_found(metadata_api, mock_auth): post_event_response = handler.post_events(post_event_data.event_not_found, {}) assert post_event_response == post_event_data.not_found_response
def test_post_single_event(metadata_api, mock_auth, mock_stream_name): stream_name = post_event_data.stream_name create_event_stream(stream_name) post_event_response = handler.post_events( post_event_data.event_with_object, {}) assert post_event_response == post_event_data.ok_response
def test_post_events_forbidden(metadata_api, mock_auth): response = handler.post_events(post_event_data.event_access_denied, {}) assert response == post_event_data.forbidden_response
def test_post_events_decode_error(metadata_api, mock_auth): post_event_response = handler.post_events( post_event_data.decode_error_event, {}) assert post_event_response == post_event_data.decode_error_response