Example #1
0
 def reload(self):
     ans = input(
         'This will delete cached images and redownload them. Proceed?\n')
     if ans == 'y' or not ans:
         os.system(f'rm -r {self._main_path}')  # shutil.rmtree is better
         self.__init__(self._input)
         self.start()
     prompt.user_prompt(self)
Example #2
0
 def go_artist_mode(self, selected_user_num):
     try:
         artist_user_id = self.data.artist_user_id(self._page_num,
                                                   selected_user_num)
     except IndexError:
         print('Invalid number!')
     else:
         main.ArtistGalleryMode(artist_user_id)
         # After backing from gallery
         self._show_page()
         prompt.user_prompt(self)
Example #3
0
    def go_artist_mode(self, selected_user_num: int) -> 'IO':
        """Concrete method unique for both user modes"""
        try:
            artist_user_id = self._data.artist_user_id(selected_user_num)
        except IndexError:
            print('Invalid number!')
            return False

        mode = ArtistGallery(artist_user_id)
        prompt.gallery_like_prompt(mode)
        # After backing from gallery
        self._show_page()
        prompt.user_prompt(self)
Example #4
0
def test_user_prompt_seq(monkeypatch, patch_cbreak, capsys):
    class FakeInKey1(FakeInKey):
        def __call__(self):
            return Keystroke(ucs='1', code=1, name='1')

    fake_inkey = iter([FakeInKey1()])
    monkeypatch.setattr('koneko.prompt.TERM.inkey', next(fake_inkey))
    with pytest.raises(CustomExit):
        assert prompt.user_prompt(fakeuser)

    captured = capsys.readouterr()
    assert captured.out == 'Enter a user view command:\n11'
Example #5
0
def test_user_prompt(monkeypatch, patch_cbreak, letter, capsys):
    monkeypatch.setattr('koneko.prompt.ask_quit', raises_customexit)
    monkeypatch.setattr('koneko.ui.AbstractUsers.previous_page',
                        raises_customexit)

    class FakeInKeyNew(FakeInKey):
        def __call__(self):
            return Keystroke(ucs=letter, code=1, name=letter)

    fake_inkey = FakeInKeyNew()
    monkeypatch.setattr('koneko.prompt.TERM.inkey', fake_inkey)
    with pytest.raises(CustomExit):
        assert prompt.user_prompt(fakeuser)

    captured = capsys.readouterr()
    assert captured.out == f'Enter a user view command:\n{letter}'
Example #6
0
 def _go_to_mode(self):
     self.mode = ui.FollowingUsers(self._user_input)
     self.mode.start()
     prompt.user_prompt(self.mode)
Example #7
0
 def _go_to_mode(self):
     self.mode = ui.SearchUsers(self._user_input)
     self.mode.start()
     prompt.user_prompt(self.mode)
Example #8
0
 def _go_to_mode(self) -> 'IO':
     """Implements abstractmethod: Go to mode 4"""
     os.system('clear')
     self.mode = ui.SearchUsers(self._user_input)
     prompt.user_prompt(self.mode)
Example #9
0
def following_users_mode():
    """Get pixiv id then immediately goes to ui.FollowingUsers"""
    os.system('clear')
    pixiv_id = get_id_then_save()
    mode = ui.FollowingUsers(pixiv_id)
    prompt.user_prompt(mode)
Example #10
0
 def _go_to_mode(self):
     """Implements abstractmethod: Go to mode 3"""
     os.system('clear')
     self.mode = ui.FollowingUsers(self._user_input)
     prompt.user_prompt(self.mode)
     main()