diff options
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/data/dirty.torrent | bin | 0 -> 93903 bytes | |||
| -rw-r--r-- | tests/test_libmat2.py | 23 |
2 files changed, 22 insertions, 1 deletions
diff --git a/tests/data/dirty.torrent b/tests/data/dirty.torrent new file mode 100644 index 0000000..472371b --- /dev/null +++ b/tests/data/dirty.torrent | |||
| Binary files differ | |||
diff --git a/tests/test_libmat2.py b/tests/test_libmat2.py index ae04dc2..ff5c196 100644 --- a/tests/test_libmat2.py +++ b/tests/test_libmat2.py | |||
| @@ -6,7 +6,7 @@ import os | |||
| 6 | import zipfile | 6 | import zipfile |
| 7 | import tempfile | 7 | import tempfile |
| 8 | 8 | ||
| 9 | from src import pdf, images, audio, office, parser_factory | 9 | from src import pdf, images, audio, office, parser_factory, torrent |
| 10 | 10 | ||
| 11 | 11 | ||
| 12 | class TestParserFactory(unittest.TestCase): | 12 | class TestParserFactory(unittest.TestCase): |
| @@ -28,6 +28,11 @@ class TestGetMeta(unittest.TestCase): | |||
| 28 | "3.1415926-2.5-1.40.14 (TeX Live 2013/Debian) kpathsea " \ | 28 | "3.1415926-2.5-1.40.14 (TeX Live 2013/Debian) kpathsea " \ |
| 29 | "version 6.1.1") | 29 | "version 6.1.1") |
| 30 | 30 | ||
| 31 | def test_torrent(self): | ||
| 32 | p = torrent.TorrentParser('./tests/data/dirty.torrent') | ||
| 33 | meta = p.get_meta() | ||
| 34 | self.assertEqual(meta['created by'], b'mktorrent 1.0') | ||
| 35 | |||
| 31 | def test_png(self): | 36 | def test_png(self): |
| 32 | p = images.PNGParser('./tests/data/dirty.png') | 37 | p = images.PNGParser('./tests/data/dirty.png') |
| 33 | meta = p.get_meta() | 38 | meta = p.get_meta() |
| @@ -322,3 +327,19 @@ class TestCleaning(unittest.TestCase): | |||
| 322 | self.assertEqual(p.get_meta(), {}) | 327 | self.assertEqual(p.get_meta(), {}) |
| 323 | 328 | ||
| 324 | os.remove('./tests/data/clean.bmp') | 329 | os.remove('./tests/data/clean.bmp') |
| 330 | |||
| 331 | |||
| 332 | def test_torrent(self): | ||
| 333 | shutil.copy('./tests/data/dirty.torrent', './tests/data/clean.torrent') | ||
| 334 | p = torrent.TorrentParser('./tests/data/clean.torrent') | ||
| 335 | |||
| 336 | meta = p.get_meta() | ||
| 337 | self.assertEqual(meta, {'created by': b'mktorrent 1.0', 'creation date': 1522397702}) | ||
| 338 | |||
| 339 | ret = p.remove_all() | ||
| 340 | self.assertTrue(ret) | ||
| 341 | |||
| 342 | p = torrent.TorrentParser('./tests/data/clean.torrent.cleaned') | ||
| 343 | self.assertEqual(p.get_meta(), {}) | ||
| 344 | |||
| 345 | os.remove('./tests/data/clean.torrent') | ||
