How to use the castero.queue.Queue function in castero

To help you get started, we’ve selected a few castero examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github xgi / castero / tests / test_queue.py View on Github external
def test_queue_init(display):
    myqueue = Queue(display)
    assert isinstance(myqueue, Queue)
github xgi / castero / tests / test_menu_queue.py View on Github external
from unittest import mock

from castero.episode import Episode
from castero.player import Player
from castero.queue import Queue
from castero.feed import Feed
from castero.menus.queuemenu import QueueMenu

feed = mock.MagicMock(spec=Feed)
player1 = mock.MagicMock(spec=Player)
player2 = mock.MagicMock(spec=Player)
player1.episode = mock.MagicMock(spec=Episode)
window = mock.MagicMock()
window.getmaxyx = mock.MagicMock(return_value=(40, 80))
source = mock.MagicMock(spec=Queue)
source.__iter__.return_value = [player1, player2]
source.__getitem__.return_value = player1


def test_menu_queue_init():
    mymenu = QueueMenu(window, source)
    assert isinstance(mymenu, QueueMenu)


def test_menu_queue_update_items():
    mymenu = QueueMenu(window, source)
    mymenu.update_items(None)
    assert len(mymenu._items) == 2


@mock.patch('curses.A_NORMAL')
github xgi / castero / tests / test_queue.py View on Github external
def test_queue_jump(display):
    myqueue = Queue(display)
    player1 = mock.MagicMock(spec=Player)
    player2 = mock.MagicMock(spec=Player)

    myqueue.add(player1)
    myqueue.add(player2)
    assert myqueue.length == 2
    myqueue.jump(player2)
    assert myqueue.length == 1
github xgi / castero / tests / test_queue.py View on Github external
def test_queue_seek_backward(display):
    myqueue = Queue(display)
    player1 = mock.MagicMock(spec=Player)

    myqueue.add(player1)
    myqueue.seek(-1)
    player1.seek.assert_called_with(-1, int(Config["seek_distance_backward"]))
github xgi / castero / tests / test_queue.py View on Github external
def test_queue_play(display):
    myqueue = Queue(display)
    player1 = mock.MagicMock(spec=Player)

    myqueue.add(player1)
    myqueue.play()
    assert player1.play.call_count == 1
github xgi / castero / tests / test_queue.py View on Github external
def test_queue_next(display):
    myqueue = Queue(display)
    player1 = mock.MagicMock(spec=Player)
    player2 = mock.MagicMock(spec=Player)

    myqueue.add(player1)
    myqueue.add(player2)
    assert myqueue.length == 2
    myqueue.next()
    assert myqueue.length == 1
github xgi / castero / tests / test_queue.py View on Github external
def test_queue_get(display):
    myqueue = Queue(display)
    player1 = mock.MagicMock(spec=Player)
    player2 = mock.MagicMock(spec=Player)

    myqueue.add(player1)
    myqueue.add(player2)
    retrieved_player1 = myqueue[0]
    assert retrieved_player1 == player1
    retrieved_player2 = myqueue[1]
    assert retrieved_player2 == player2
github xgi / castero / tests / test_queue.py View on Github external
def test_queue_toggle(display):
    myqueue = Queue(display)
    player1 = mock.MagicMock(spec=Player)

    myqueue.add(player1)
    myqueue.toggle()
    assert player1.play.call_count == 1
    player1.state = 1
    myqueue.toggle()
    assert player1.pause.call_count == 1
github xgi / castero / tests / test_queue.py View on Github external
def test_queue_add(display):
    myqueue = Queue(display)
    player1 = mock.MagicMock(spec=Player)

    myqueue.add(player1)
    assert myqueue.length == 1
github xgi / castero / castero / display.py View on Github external
def __init__(self, stdscr, database) -> None:
        """
        Args:
            stdscr: a stdscr from curses.initscr()
            database: a connected castero.Database
        """
        self._stdscr = stdscr
        self._database = database
        self._parent_x = -1
        self._parent_y = -1
        self._perspectives = {}
        self._active_perspective = 1
        self._header_window = None
        self._footer_window = None
        self._queue = Queue(self)
        self._download_queue = DownloadQueue(self)
        self._status = ""
        self._status_timer = self.STATUS_TIMEOUT
        self._menus_valid = True
        self._modified_episodes = []

        # basic preliminary operations
        self._stdscr.timeout(self.INPUT_TIMEOUT)
        curses.start_color()
        curses.use_default_colors()
        curses.noecho()
        curses.curs_set(0)
        curses.cbreak()
        self._stdscr.keypad(True)

        self.update_parent_dimensions()