summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHans Ole Hatzel <hhatzel@gmail.com>2020-05-27 23:13:19 +0200
committerCalum Lind <calumlind+deluge@gmail.com>2021-03-24 10:26:08 +0000
commitdcd3918f3626403e32f00993d0a6e7014be3cbf3 (patch)
tree8b1b01c4cc9ac71d03fe1e52c3e7234cb84ad07b
parent08c7f1960fd1c00059883186f59379cd92f8a55a (diff)
downloaddeluge-dcd3918f3626403e32f00993d0a6e7014be3cbf3.zip
deluge-dcd3918f3626403e32f00993d0a6e7014be3cbf3.tar.gz
deluge-dcd3918f3626403e32f00993d0a6e7014be3cbf3.tar.bz2
[WebUI] Add test for torrent files containing md5sums
Some torrent files built with py3createtorrent fail to produce a file listing in the WebUI when uploading them. This made it impossible to add such files. Specifically this is caused by the additional metadata when using py3createtorrent with the `--md5` flag.
-rw-r--r--deluge/tests/data/md5sum.torrent1
-rw-r--r--deluge/tests/test_web_api.py11
2 files changed, 12 insertions, 0 deletions
diff --git a/deluge/tests/data/md5sum.torrent b/deluge/tests/data/md5sum.torrent
new file mode 100644
index 0000000..0e8c93f
--- /dev/null
+++ b/deluge/tests/data/md5sum.torrent
@@ -0,0 +1 @@
+d8:announce25:lol.this.is.not.a.tracker7:comment36:created with py3createtorrent v0.9.610:created by23:py3createtorrent v0.9.613:creation datei1590076175e4:infod5:filesld6:lengthi4e6:md5sum32:59bcc3ad6775562f845953cf016242254:pathl3:loleed6:lengthi5e6:md5sum32:10245815f893d79f3d779690774f0b434:pathl4:rofleee4:name4:test12:piece lengthi16384e6:pieces20:86Aڲ-Y>+S]\/ee \ No newline at end of file
diff --git a/deluge/tests/test_web_api.py b/deluge/tests/test_web_api.py
index 982a93b..0180e0b 100644
--- a/deluge/tests/test_web_api.py
+++ b/deluge/tests/test_web_api.py
@@ -9,6 +9,7 @@
from __future__ import unicode_literals
+import json
from io import BytesIO
from twisted.internet import defer, reactor
@@ -130,6 +131,16 @@ class WebAPITestCase(WebServerTestBase):
self.assertEqual(ret['info_hash'], 'ab570cdd5a17ea1b61e970bb72047de141bce173')
self.assertTrue('files_tree' in ret)
+ def test_get_torrent_info_with_md5(self):
+ filename = common.get_test_data_file('md5sum.torrent')
+ ret = self.deluge_web.web_api.get_torrent_info(filename)
+ # JSON dumping happens during response creation in normal usage
+ # JSON serialization may fail if any of the dictionary items are byte arrays rather than strings
+ ret = json.loads(json.dumps(ret))
+ self.assertEqual(ret['name'], 'test')
+ self.assertEqual(ret['info_hash'], 'f6408ba9944cf9fe01b547b28f336b3ee6ec32c5')
+ self.assertTrue('files_tree' in ret)
+
def test_get_magnet_info(self):
ret = self.deluge_web.web_api.get_magnet_info(
'magnet:?xt=urn:btih:SU5225URMTUEQLDXQWRB2EQWN6KLTYKN'