def test_config_assistant_6(monkeypatch, capsys, send_enter, argv): monkeypatch.setattr('koneko.lscat_app.sys.argv', [True, '1'] + argv) monkeypatch.setattr('koneko.picker.ask_assistant', lambda: [6]) monkeypatch.setattr('koneko.assistants.user_info_assistant', lambda *a: 99) lscat_app.main() captured = capsys.readouterr() assert captured.out == '\n\nYour recommended settings are:\nusers_print_name_xcoord = 99\n'
def test_config_assistant_5(monkeypatch, capsys, send_enter, argv): monkeypatch.setattr('koneko.lscat_app.sys.argv', [True, '1'] + argv) monkeypatch.setattr('koneko.picker.ask_assistant', lambda: [5]) monkeypatch.setattr('koneko.assistants.gallery_print_spacing_assistant', lambda *a: range(5)) lscat_app.main() captured = capsys.readouterr() assert captured.out == '\n\nYour recommended settings are:\ngallery_print_spacing = 0,1,2,3,4\n'
def test_config_assistant_4(monkeypatch, capsys, send_enter, argv): monkeypatch.setattr('koneko.lscat_app.sys.argv', [True, '1'] + argv) monkeypatch.setattr('koneko.picker.ask_assistant', lambda: [4]) monkeypatch.setattr('koneko.assistants.page_spacing_assistant', lambda x: 99) lscat_app.main() captured = capsys.readouterr() assert captured.out == '\n\nYour recommended settings are:\npage_spacing = 99\n'
def test_display_path_cli_invalid_quits(monkeypatch, capsys): mock = Mock() monkeypatch.setattr('koneko.lscat_app.sys.argv', [True, '3', 'notapath']) monkeypatch.setattr('koneko.picker.lscat_app_main', lambda: 2) monkeypatch.setattr('koneko.lscat.show_instant', mock) monkeypatch.setattr('koneko.lscat_app.sys.exit', raises_customexit) with pytest.raises(CustomExit): lscat_app.main() captured = capsys.readouterr() assert captured.out == 'Invalid path!\n'
def test_browse_cache_image(monkeypatch, tmp_path, argv): path = tmp_path / 'individual' path.mkdir() (path / 'somefile').touch() mock = Mock() monkeypatch.setattr('koneko.lscat_app.sys.argv', [True] + argv) monkeypatch.setattr('koneko.lscat_prompt.ImageLoop', mock) monkeypatch.setattr('koneko.picker.lscat_app_main', lambda: 1) monkeypatch.setattr('koneko.picker.pick_dir', lambda: path) lscat_app.main() assert mock.mock_calls == [call(path), call().start()]
def test_browse_cache_noinvis(monkeypatch, tmp_path, argv): mock = Mock() monkeypatch.setattr('koneko.lscat_app.sys.argv', [True] + argv) monkeypatch.setattr('koneko.lscat_prompt.GalleryUserLoop', mock) monkeypatch.setattr('koneko.picker.lscat_app_main', lambda: 1) monkeypatch.setattr('koneko.picker.pick_dir', lambda: tmp_path) lscat_app.main() assert mock.mock_calls == [ call.for_gallery( FakeData(tmp_path), ), call.for_gallery().start() ]
def test_display_path_cli_complete(monkeypatch, tmp_path): mock = Mock() monkeypatch.setattr('koneko.lscat_app.sys.argv', [True, '3', str(tmp_path)]) monkeypatch.setattr('koneko.lscat_prompt.GalleryUserLoop', mock) monkeypatch.setattr('koneko.picker.lscat_app_main', lambda: 2) lscat_app.main() assert mock.call_args_list == [] assert mock.mock_calls == [ call.for_gallery( FakeData(tmp_path), ), call.for_gallery().start() ]
def test_display_user(monkeypatch, argv): mock = Mock() monkeypatch.setattr('koneko.lscat_app.sys.argv', [True] + argv) monkeypatch.setattr('koneko.lscat.show_instant', mock) monkeypatch.setattr('koneko.config.api.use_ueberzug', lambda: False) monkeypatch.setattr('koneko.config.api.scroll_display', lambda: True) monkeypatch.setattr('koneko.picker.lscat_app_main', lambda: 4) lscat_app.main() assert mock.mock_calls == mock.call_args_list == [ call( lscat.TrackDownloadsUsers, FakeData(KONEKODIR / 'testuser') ) ]
def test_display_path_cli_incomplete(monkeypatch, tmp_path): mock = Mock() monkeypatch.setattr('koneko.lscat_app.sys.argv', [True, '3']) monkeypatch.setattr('koneko.lscat_prompt.GalleryUserLoop', mock) monkeypatch.setattr('koneko.picker.lscat_app_main', lambda: 2) responses = iter((str(tmp_path),)) monkeypatch.setattr('builtins.input', lambda x=None: next(responses)) lscat_app.main() assert mock.call_args_list == [] assert mock.mock_calls == [ call.for_gallery( FakeData(tmp_path), ), call.for_gallery().start() ]