Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 34 additions & 1 deletion tests/test_edit.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
"""
Expand Down Expand Up @@ -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):
"""
Expand Down
2 changes: 1 addition & 1 deletion torrentfile/edit.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down