def test_start_error(mocker): mock_start_project = mocker.patch('aiohttp_devtools.cli.StartProject') mocker.patch('aiohttp_devtools.cli.check_dir_clean') mock_start_project.side_effect = AiohttpDevException('foobar') runner = CliRunner() result = runner.invoke(cli, ['start', 'foobar']) assert result.exit_code == 2 assert mock_start_project.call_count == 1
def test_runserver_error(mocker): mock_run_app = mocker.patch('aiohttp_devtools.cli.run_app') mock_run_app.side_effect = AiohttpDevException('foobar') mock_runserver = mocker.patch('aiohttp_devtools.cli._runserver') runner = CliRunner() result = runner.invoke(cli, ['runserver', '.']) assert result.exit_code == 2 assert 'Error: foobar\n' == result.output assert mock_run_app.call_count == 1 assert mock_runserver.call_count == 1