示例#1
0
def test_asynction_socketio_from_spec_path_kwarg_takes_precedence_over_server_name(
    fixture_paths: FixturePaths, ):
    p = "/async/socket.io"
    asio = AsynctionSocketIO.from_spec(
        spec_path=fixture_paths.simple_with_servers,
        path=p,
        server_name="production")
    assert asio.server_options["path"] == p
示例#2
0
def test_asynction_socketio_from_spec_registers_default_error_handler(
    fixture_paths: FixturePaths, ):
    def my_default_error_handler(_):
        # dummy handler
        pass

    asio = AsynctionSocketIO.from_spec(
        spec_path=fixture_paths.simple,
        default_error_handler=my_default_error_handler,
        app=mock.MagicMock(
        ),  # app needs to be defined in order to register handlers
    )

    assert asio.default_exception_handler == my_default_error_handler
示例#3
0
def test_asynction_socketio_from_spec_raises_value_error_for_non_existent_server_name(
    fixture_paths: FixturePaths, ):
    with pytest.raises(ValueError):
        AsynctionSocketIO.from_spec(
            spec_path=fixture_paths.simple_with_servers,
            server_name="not-production")
示例#4
0
def test_asynction_socketio_from_spec_empty_server_path_is_ignored(
    fixture_paths: FixturePaths, ):
    asio = AsynctionSocketIO.from_spec(
        spec_path=fixture_paths.simple_with_servers, server_name="development")
    assert "path" not in asio.server_options
示例#5
0
def test_asynction_socketio_from_spec_uses_spec_server_path_as_socketio_path(
    fixture_paths: FixturePaths, ):
    asio = AsynctionSocketIO.from_spec(
        spec_path=fixture_paths.simple_with_servers, server_name="production")
    assert asio.server_options["path"] == "/api/socket.io"
示例#6
0
def test_asynction_socketio_from_spec_object(fixture_paths: FixturePaths):
    with open(fixture_paths.simple, "r") as simple:
        spec = yaml.safe_load(simple)
    asio = AsynctionSocketIO.from_spec(spec_path=spec)
    assert isinstance(asio, AsynctionSocketIO)
示例#7
0
def test_asynction_socketio_from_spec(fixture_paths: FixturePaths):
    asio = AsynctionSocketIO.from_spec(spec_path=fixture_paths.simple)
    assert isinstance(asio, AsynctionSocketIO)