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")), ] )
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()
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()
def update_wrapper(ret): update(name=ret.name, download=ret.download, not_ignore=ret.not_ignore)
def update_wrapper(ret: Any) -> None: update(name=ret.name, download=ret.download, not_ignore=ret.not_ignore)