def test_raises_error_only_codes_unexpected_missing(test_error, auth_missing_error): errors = [test_error, auth_missing_error] with pytest.raises(pytest.raises.Exception): with raises_only_error_codes('UNAUTHORIZED'): raise Client.CallActionError( actions=[ActionResponse(action='', errors=errors)] )
def test_raises_error_codes_missing(codes): errors = [Error(code=code, message='bam') for code in codes] with pytest.raises(pytest.raises.Exception): with raises_error_codes(['AUTH_MISSING']): raise Client.CallActionError( actions=[ActionResponse(action='', errors=errors)] )
def test_raises_error_only_codes_unexpected_field_error(invalid_event_id_field_error, auth_missing_error): errors = [invalid_event_id_field_error, auth_missing_error] with pytest.raises(pytest.raises.Exception): with raises_only_error_codes('AUTH_MISSING'): raise Client.CallActionError( actions=[ActionResponse(action='', errors=errors)] )
def test_raises_only_error_codes_unexpected(test_error, auth_missing_error): errors = [test_error, auth_missing_error] with pytest.raises(pytest.raises.Exception): with raises_only_error_codes(['AUTH_MISSING']): raise Client.CallActionError( actions=[ActionResponse(action='', errors=errors)] )
def test_raises_error_codes_multiple(codes): errors = [Error(code=code, message='bam') for code in codes] with raises_error_codes(['TEST', 'AUTH_MISSING']) as exc_info: raise Client.CallActionError( actions=[ActionResponse(action='', errors=errors)] ) assert exc_info.soa_errors == errors
def test_raises_error_codes_on_match(test_error): errors = [test_error] with raises_error_codes('TEST') as exc_info: raise Client.CallActionError( actions=[ActionResponse(action='', errors=errors)] ) assert exc_info.soa_errors == errors
def test_raises_call_action_error_on_error(test_error): errors = [test_error] with raises_call_action_error() as exc_info: raise Client.CallActionError( actions=[ActionResponse(action='', errors=errors)] ) assert exc_info.soa_errors == errors
def test_raises_field_errors_match_multiple(codes): errors = [Error(code=code, field=field, message='bam') for field, code in codes] with raises_field_errors({'event_id': 'UNKNOWN', 'organization_id': 'INVALID'}) as exc_info: raise Client.CallActionError( actions=[ActionResponse(action='', errors=errors)] ) assert exc_info.soa_errors == errors
def test_raises_field_errors_on_match(invalid_event_id_field_error): errors = [invalid_event_id_field_error] with raises_field_errors({'event_id': 'INVALID'}) as exc_info: raise Client.CallActionError( actions=[ActionResponse(action='', errors=errors)] ) assert exc_info.soa_errors == errors
def test_raises_only_error_codes_match(test_error, auth_missing_error): errors = [test_error, auth_missing_error] with raises_only_error_codes(['AUTH_MISSING', 'TEST']) as exc_info: raise Client.CallActionError( actions=[ActionResponse(action='', errors=errors)] ) assert exc_info.soa_errors == errors
def test_raises_field_errors_missing(code, field): errors = [ Error(code=code, message='test fail', field=field), ] with pytest.raises(pytest.raises.Exception): with raises_field_errors({'event_id': 'UNKNOWN'}): raise Client.CallActionError( actions=[ActionResponse(action='', errors=errors)] )
def test_raises_only_field_errors_unexpected_missing(unknown_event_id_field_error, invalid_organization_id_field_error): errors = [ unknown_event_id_field_error, invalid_organization_id_field_error, ] with pytest.raises(pytest.raises.Exception): with raises_only_field_errors({'event_id': 'MISSING'}): raise Client.CallActionError( actions=[ActionResponse(action='', errors=errors)] )
def test_raises_only_field_errors_unexpected_error(auth_missing_error, invalid_organization_id_field_error): errors = [ auth_missing_error, invalid_organization_id_field_error, ] with pytest.raises(pytest.raises.Exception): with raises_only_field_errors({'organization_id': 'INVALID'}): raise Client.CallActionError( actions=[ActionResponse(action='', errors=errors)] )
def test_raises_field_errors_unexpected_only(invalid_event_id_field_error, unknown_event_id_field_error): errors = [ invalid_event_id_field_error, unknown_event_id_field_error, ] with pytest.raises(pytest.raises.Exception): with raises_field_errors({'event_id': ['UNKNOWN']}, only=True): raise Client.CallActionError( actions=[ActionResponse(action='', errors=errors)] )
def test_raises_only_field_errors_match(invalid_event_id_field_error, unknown_event_id_field_error): errors = [ invalid_event_id_field_error, unknown_event_id_field_error, ] with raises_only_field_errors({'event_id': ['UNKNOWN', 'INVALID']}) as exc_info: raise Client.CallActionError( actions=[ActionResponse(action='', errors=errors)] ) assert exc_info.soa_errors == errors