Exemple #1
0
def test_update_download(mock_download_driver: mock.Mock):
    """TODO: mock HTTP requests in this test"""
    name = "hello world"
    mock_website = mock.Mock()
    mock_website.get_maximum_episode = mock.Mock(
        return_value=(
            4,
            [
                Episode(episode=3, download="magnet:mm", title="t 720p", name=name),
                Episode(episode=4, download="magnet:4", title="t 1080p", name=name),
            ],
        )
    )

    Bangumi(name=name, subtitle_group="", keyword=name, cover="").save()
    Followed(bangumi_name=name, episode=2).save()

    with mock.patch("bgmi.lib.controllers.website", mock_website):
        update([], download=True, not_ignore=False)

    mock_download_driver.add_download.assert_has_calls(
        [
            mock.call(url="magnet:mm", save_path=os.path.join(SAVE_PATH, name, "3")),
            mock.call(url="magnet:4", save_path=os.path.join(SAVE_PATH, name, "4")),
        ]
    )
Exemple #2
0
    def hard_task(self, ):
        print('start work')
        data = self.get_json()

        name = data.get('name', '')
        download = data.get('download', [])

        if not download:
            download = None
        update(name, download)
        self.lock.release()
Exemple #3
0
    def hard_task(self) -> None:
        print("start work")
        data = self.get_json()

        name = data.get("name", "")
        download = data.get("download", [])

        if not download:
            download = None
        update(name, download)
        self.lock.release()
Exemple #4
0
def update_wrapper(ret):
    update(name=ret.name, download=ret.download, not_ignore=ret.not_ignore)
Exemple #5
0
def update_wrapper(ret):
    update(name=ret.name, download=ret.download, not_ignore=ret.not_ignore)
Exemple #6
0
def update_wrapper(ret: Any) -> None:
    update(name=ret.name, download=ret.download, not_ignore=ret.not_ignore)