def test_frequent(monkeypatch, capsys): mock = Mock() monkeypatch.setattr('koneko.cli.sys.argv', (['koneko', 'q'])) monkeypatch.setattr('koneko.cli.main.frequent', mock) args = cli.handle_vh() assert cli.launch_mode(args) assert mock.call_args_list == [call()] capture_logging_in(capsys)
def test_mode6(monkeypatch, mode, capsys): mock = Mock() monkeypatch.setattr('koneko.cli.sys.argv', (['koneko', mode])) monkeypatch.setattr('koneko.cli.main.illust_recommended_mode', mock) args = cli.handle_vh() assert cli.launch_mode(args) assert mock.call_args_list == [call()] capture_logging_in(capsys)
def test_mode4(monkeypatch, args, capsys): mock = Mock() monkeypatch.setattr('koneko.cli.sys.argv', (['koneko'] + args)) monkeypatch.setattr('koneko.cli.main.SearchUsersModeLoop', mock) args = cli.handle_vh() assert cli.launch_mode(args) assert mock.call_args_list == [call('searchstring')] assert mock.mock_calls == [call('searchstring'), call().start()] capture_logging_in(capsys)
def test_mode3(monkeypatch, args, capsys): mock = Mock() monkeypatch.setattr('koneko.cli.sys.argv', (['koneko'] + args)) monkeypatch.setattr('koneko.cli.main.following_users_mode', mock) args = cli.handle_vh() assert cli.launch_mode(args) assert mock.call_args_list == [call()] assert mock.mock_calls == [call()] capture_logging_in(capsys)
def test_help(monkeypatch, arg, capsys): monkeypatch.setattr( 'koneko.cli.docopt', lambda x: { '-h': True, '--help': True, '-v': False, '--version': False }) monkeypatch.setattr('koneko.cli.sys.argv', (['koneko', arg])) assert cli.handle_vh() is False captured = capsys.readouterr() assert captured.out == cli.__doc__ + '\n'
def _main() -> 'IO': """Read config file, start login, process any cli arguments, go to main loop""" if not (args := cli.handle_vh()): sys.exit(0)
def test_version(monkeypatch, arg, capsys): monkeypatch.setattr('koneko.cli.sys.argv', (['koneko', arg])) assert cli.handle_vh() is False captured = capsys.readouterr() assert captured.out == f'{__version__}\n'