def test_copy_to_deflist(self, caplog, id_and_name_to): caplog.set_level(logging.DEBUG) c = "{} --to {} --copy {}".format(id_and_name_to.name, "とりあえずマイリスト", VIDEO_ID) try: nicotools.main(param(c)) except utils.MylistAPIError as error: if not error.ok: print(error, file=sys.stderr)
def test_del_from_deflist(self, caplog): caplog.set_level(logging.DEBUG) c = "{} --delete {}".format("とりあえずマイリスト", VIDEO_ID) try: nicotools.main(param(c)) except utils.MylistAPIError as error: if not error.ok: print(error, file=sys.stderr)
def test_show_everything_tsv(self, caplog): caplog.set_level(logging.DEBUG) c = "* --show --everything" try: nicotools.main(param(c)) except utils.MylistAPIError as error: if not error.ok: print(error, file=sys.stderr)
def test_list_not_exists_and_create_special_characters_name(self, instance): c = "{} --show".format(INSANE_NAME) with pytest.raises(SystemExit): nicotools.main(param(c)) instance.create_mylist(INSANE_NAME) # 作ったばかりなのでマイリストIDは、手持ちの中で最大。 insane_id = max(instance.mylists) instance.purge_mylist(insane_id, confident=True)
def test_delete_not_existing_items(self): c = "とりあえずマイリスト --add {}".format(VIDEO_ID) assert nicotools.main(param(c)) c = "とりあえずマイリスト --delete {}".format(VIDEO_ID) assert nicotools.main(param(c)) c = "とりあえずマイリスト --delete {}".format(VIDEO_ID) assert nicotools.main(param(c)) is False
def test_create_purge(self, id_and_name): with tempfile.TemporaryDirectory(prefix=__name__) as tmpdirname: # c = "{} --create".format(id_and_name.name) # assert nicotools.main(param(c)) c = "{} --id --export --out {}_export.txt".format( id_and_name.id, os.path.join(tmpdirname, id_and_name.name)) assert nicotools.main(param(c)) c = "{} --id --show".format(id_and_name.id) assert nicotools.main(param(c)) c = "{} --id --show --show --out {}_show.txt".format( id_and_name.id, os.path.join(tmpdirname, id_and_name.name)) assert nicotools.main(param(c)) c = "{} --id --purge --yes".format(id_and_name.id) assert nicotools.main(param(c))
def test_nicoml_del_2(self, caplog, id_and_name): caplog.set_level(logging.DEBUG) c = "{} --delete * --yes".format(id_and_name.name) try: assert nicotools.main(param(c)) except utils.MylistAPIError as error: if not error.ok: print(error, file=sys.stderr)
def test_nicoml_add_1(self, caplog, id_and_name): caplog.set_level(logging.DEBUG) c = "{} --add {}".format(id_and_name.name, VIDEO_ID) try: assert nicotools.main(param(c)) except utils.MylistAPIError as error: if not error.ok: print(error, file=sys.stderr)
def send_param(self, cond, **kwargs): if isinstance(cond, str): cond = "download -l {_mail} -p {_pass} -d {save_dir} --loglevel DEBUG " + cond params = { "_mail": AUTH_N[0], "_pass": AUTH_N[1], "save_dir": SAVE_DIR_1, "video_id": " ".join(rand(0)) } params.update(kwargs) arg = cond.format(**params).split(" ") else: arg = cond return nicotools.main(arg, async_=is_async)
def send_param(self, cond, **kwargs): if is_async: cond = "download --nomulti -l {_mail} -p {_pass} -d {save_dir} --loglevel DEBUG " + cond time.sleep(1) else: cond = "download -l {_mail} -p {_pass} -d {save_dir} --loglevel DEBUG " + cond params = { "_mail": AUTH_N[0], "_pass": AUTH_N[1], "save_dir": SAVE_DIR_1, "video_id": " ".join(rand(0)) } params.update(kwargs) return nicotools.main(cond.format(**params).split(" "), async_=is_async)
def test_no_args(self): with pytest.raises(SystemExit): nicotools.main(self.make_param(cond=None))
def test_invalid_directory_on_windows(self): if os.name == "nt": with pytest.raises(SystemExit): nicotools.main(self.make_param("-c {video_id}", save_dir="nul"))
def test_without_commands(self): with pytest.raises(SystemExit): nicotools.main(self.make_param("{video_id}"))
def test_video_dmc_more(self): cond = "--limit 10 -v {video_id}" assert nicotools.main(self.make_param(cond))
def test_video_dmc(self): cond = "-v {video_id}" assert nicotools.main(self.make_param(cond))
def test_copy_to_same(self): with pytest.raises(SystemExit): c = "{} --copy * --to {}".format("なまえ", "なまえ") nicotools.main(param(c))
def test_invalid_videoid(self): with pytest.raises(SystemExit): nicotools.main(self.make_param(["download", "-c", "sm9", "hello"]))
def close(cls): # 終わったら片付けるための関数 c = "{} --purge --id --yes".format(cls.id) nicotools.main(param(c))
def test_export_meta(self): c = "* --export" assert nicotools.main(param(c))
def test_show_meta_table(self): c = "* --show --show" assert nicotools.main(param(c))
def test_no_commands(self): with pytest.raises(SystemExit): c = "とりあえずマイリスト" nicotools.main(param(c))
def test_delete_ambiguous(self): with pytest.raises(SystemExit): c = "とりあえずマイリスト --delete sm9 *" nicotools.main(param(c))
def test_copy_without_to(self): with pytest.raises(SystemExit): c = "とりあえずマイリスト --copy *" nicotools.main(param(c))
def test_one_arg(self): with pytest.raises(SystemExit): nicotools.main(self.make_param(["download"]))
def test_what_command(self): with pytest.raises(SystemExit): nicotools.main(self.make_param(["download", "-c", "sm9", "-w"]))
def test_add_all(self): with pytest.raises(SystemExit): c = "とりあえずマイリスト --add *" nicotools.main(param(c))
def test_notexisting(self): cond = "-v {video_id}" assert nicotools.main(self.make_param(cond, video_id="sm3"))
def test_purge_deflist(self): with pytest.raises(SystemExit): c = "とりあえずマイリスト --purge" nicotools.main(param(c))
def test_video_smile(self): cond = "--smile -v {video_id}" assert nicotools.main(self.make_param(cond))
def test_show_everything_table(self): c = "* --show --show --everything" assert nicotools.main(param(c))