示例#1
0
def test_app_configure_without_platforms(mocked_settings):
    """Should raise Exception if no platform was found at settings"""

    mocked_settings.PLATFORMS = {}
    app = App()
    with pytest.raises(Exception):
        app.configure_platforms()
示例#2
0
def test_app_configure_with_tasks(mocked_engine):
    """App should have empty tasks if not defined  on engine"""

    mocked_engine['instance'].tasks.return_value = []
    app = App()
    app.configure_platforms()

    assert not app.tasks
示例#3
0
def test_app_configure_with_platforms(mocked_engine):
    """Should call the platform interface methods"""

    app = App()
    app.configure_platforms()

    mocked_engine['module'].engine.assert_called_with(
        session=app.session, token='should-be-a-valid-token')
    mocked_engine['instance'].configure.assert_called_with()
示例#4
0
def test_app_run(mocked_asyncio):
    """Should create tasks and run forever"""

    app = App()
    app.run()
    mocked_event_loop = mocked_asyncio.get_event_loop.return_value

    mocked_asyncio.get_event_loop.assert_called_with()
    mocked_event_loop.run_forever.assert_called_with()
示例#5
0
def test_app_configure_with_multiple_tasks(mocked_engine):
    """App should have multiple tasks if defined on engine"""
    async def fake_task(session):
        await asyncio.sleep(0)

    first_task = fake_task
    second_task = fake_task

    mocked_engine['instance'].tasks = [first_task, second_task]
    app = App()
    app.configure_platforms()

    assert app.tasks == [first_task, second_task]
示例#6
0
def run(port, debug):
    app = App()

    try:
        app.run()
    except KeyboardInterrupt:
        app.stop()
示例#7
0
from bottery.app import App


app = App()
app.run()
示例#8
0
def test_app_already_configured_loop():
    app = App()
    app._loop = 'loop'
    assert app.loop == 'loop'
示例#9
0
def test_app_loop():
    app = App()
    assert isinstance(app.loop, asyncio.AbstractEventLoop)
示例#10
0
def test_app_already_configured_session():
    app = App()
    app._session = 'session'
    assert app.session == 'session'
示例#11
0
def test_app_session():
    app = App()
    assert isinstance(app.session, aiohttp.ClientSession)
示例#12
0
文件: cli.py 项目: thaisviana/bottery
def run(port, debug):
    app = App()
    app.run()
示例#13
0
def test_app_stop():
    app = App()
    app.stop()

    assert app.loop.is_closed()
    assert app.session.closed