Exemple #1
0
async def test_multiple_file_change(loop, mocker):
    mocked_awatch = mocker.patch('aiohttp_devtools.runserver.watch.awatch')
    mocked_awatch.side_effect = create_awatch_mock({('x', '/path/to/file'),
                                                    ('x', '/path/to/file2')})
    app_task = AppTask(MagicMock(), loop)
    app_task._start_process = MagicMock()
    app_task.stop_process = MagicMock()

    app_task._app = MagicMock()
    await app_task._run()
    app_task._app.src_reload.assert_called_once_with()
    app_task._session.close()
Exemple #2
0
async def test_python_no_server(loop, mocker):
    mocked_awatch = mocker.patch('aiohttp_devtools.runserver.watch.awatch')
    mocked_awatch.side_effect = create_awatch_mock({('x', '/path/to/file.py')})

    config = MagicMock()
    config.main_port = 8000
    app_task = AppTask(config, loop)
    app_task._start_process = MagicMock()
    app_task.stop_process = MagicMock()
    app_task._app = MagicMock()
    await app_task._run()
    assert app_task._app.src_reload.called is False
    assert app_task._start_process.called
    assert app_task.stop_process.called
    app_task._session.close()