示例#1
0
def test_baseengine_handler_not_found():
    fake_handler = type('Handler', (object, ), {'check': lambda msg: False})

    view = True
    engine = BaseEngine()
    engine.registered_handlers = [(fake_handler, view)]
    returned_view = engine.discovery_view('new message')
    assert not returned_view
示例#2
0
def test_baseengine_handling_message():
    fake_handler = type('Handler', (object,), {'check': lambda msg: True})

    view = True
    engine = BaseEngine()
    engine.registered_patterns = [(fake_handler, view)]
    returned_view = engine.discovery_view('new message')
    assert returned_view
示例#3
0
async def test_get_response_from_views(view):
    """
    Test if get_response can call an async/sync view and get its response.
    """

    engine = BaseEngine()
    response = await engine.get_response(view, 'ping')
    assert response == 'pong'
示例#4
0
async def test_baseengine_not_implemented_calls(method_name):
    """Check if method calls from public API raise NotImplementedError"""
    engine = BaseEngine()
    with pytest.raises(NotImplementedError):
        method = getattr(engine, method_name)
        if inspect.iscoroutinefunction(method):
            await method()
        else:
            method()
示例#5
0
def test_baseengine_platform_name_not_implemented():
    """Check if attributes from the public API raise NotImplementedError"""
    engine = BaseEngine()
    with pytest.raises(NotImplementedError):
        getattr(engine, 'platform')
示例#6
0
def test_baseengine_attrs(attr):
    """Check if attributes from the public API raise NotImplementedError"""
    engine = BaseEngine()
    with pytest.raises(NotImplementedError):
        getattr(engine, attr)
示例#7
0
def test_baseengine_calls(method_name):
    """Check if method calls from public API raise NotImplementedError"""
    engine = BaseEngine()
    with pytest.raises(NotImplementedError):
        method = getattr(engine, method_name)
        method()