diff --git a/tests/test_edit.py b/tests/test_edit.py index cf3c973..ed02cd3 100644 --- a/tests/test_edit.py +++ b/tests/test_edit.py @@ -197,7 +197,7 @@ def test_edit_removal(metafile2): @pytest.mark.parametrize("announce", [["url1", "url2", "url3"], ["url1"]]) @pytest.mark.parametrize("webseed", [["ftp1"], ["ftpa", "ftpb"]]) @pytest.mark.parametrize("httpseed", [["ftp1"], ["ftpa", "ftpb"]]) -def test_edit_cli(metafile2, comment, source, announce, webseed, httpseed): +def test_edit_cli_private(metafile2, comment, source, announce, webseed, httpseed): """ Test edit torrent with all params on cli. """ @@ -226,6 +226,39 @@ def test_edit_cli(metafile2, comment, source, announce, webseed, httpseed): assert meta["announce-list"] == [[announce]] assert meta["url-list"] == [webseed] +@pytest.mark.parametrize("comment", ["commenta", "commentb", "commentc"]) +@pytest.mark.parametrize("source", ["sourcea", "sourceb", "sourcec"]) +@pytest.mark.parametrize("announce", [["url1", "url2", "url3"], ["url1"]]) +@pytest.mark.parametrize("webseed", [["ftp1"], ["ftpa", "ftpb"]]) +@pytest.mark.parametrize("httpseed", [["ftp1"], ["ftpa", "ftpb"]]) +def test_edit_cli_public(metafile2, comment, source, announce, webseed, httpseed): + """ + Test edit torrent with all params on cli. + """ + sys.argv = [ + "torrentfile", + "edit", + metafile2, + "--comment", + comment, + "--source", + source, + "--web-seed", + webseed, + "--http-seed", + httpseed, + "--tracker", + announce, + ] + main() + meta = pyben.load(metafile2) + info = meta["info"] + assert comment == info.get("comment") + assert source == info.get("source") + assert info.get("private") == 0 + assert meta["announce-list"] == [[announce]] + assert meta["url-list"] == [webseed] + def test_metafile_edit_with_unicode(metafile2): """ diff --git a/torrentfile/edit.py b/torrentfile/edit.py index 0c91b87..12272a7 100644 --- a/torrentfile/edit.py +++ b/torrentfile/edit.py @@ -90,7 +90,7 @@ def edit_torrent(metafile: str, args: dict) -> dict: info["source"] = args["source"] if "private" in args: - info["private"] = 1 + info["private"] = int(args["private"]) if "announce" in args: val = args.get("announce", None)