Skip to content

Provide a way to access disconnect reason & connect error in FlaskIOTestClient #1518

Description

@wbobeirne

Is your feature request related to a problem? Please describe.

Our codebase has a bunch of specific disconnect reasons that we'd like to write tests for (Too many connections, bad authentication, etc.) Right now we write the tests just checking if is_connected() == False, however it would be nice if we could test which error came back.

Describe the solution you'd like

Something to the tune of:

assert(sio.is_connected() == False)
assert(sio.get_connect_error().message == 'MY_CUSTOM_ERROR_CODE')
assert(sio.get_disconnect_reason() == 'io server disconnect')

They could also raise if you're still connected ala get_received

Describe alternatives you've considered

I could mock the functions to check when they raise or disconnect, but this ties my tests really tightly to the server implementation. It would be nice if I could do some refactoring without having to update my test mocks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions