diff options
Diffstat (limited to 'tests/test_libmat2.py')
| -rw-r--r-- | tests/test_libmat2.py | 66 |
1 files changed, 0 insertions, 66 deletions
diff --git a/tests/test_libmat2.py b/tests/test_libmat2.py index 0df333d..b34e7a4 100644 --- a/tests/test_libmat2.py +++ b/tests/test_libmat2.py | |||
| @@ -40,72 +40,6 @@ class TestUnsupportedEmbeddedFiles(unittest.TestCase): | |||
| 40 | self.assertFalse(p.remove_all()) | 40 | self.assertFalse(p.remove_all()) |
| 41 | os.remove('./tests/data/clean.docx') | 41 | os.remove('./tests/data/clean.docx') |
| 42 | 42 | ||
| 43 | class TestUnsupportedFiles(unittest.TestCase): | ||
| 44 | def test_pdf(self): | ||
| 45 | shutil.copy('./tests/test_libmat2.py', './tests/clean.py') | ||
| 46 | parser, mimetype = parser_factory.get_parser('./tests/data/clean.py') | ||
| 47 | self.assertEqual(mimetype, 'text/x-python') | ||
| 48 | self.assertEqual(parser, None) | ||
| 49 | os.remove('./tests/clean.py') | ||
| 50 | |||
| 51 | class TestExplicitelyUnsupportedFiles(unittest.TestCase): | ||
| 52 | def test_pdf(self): | ||
| 53 | shutil.copy('./tests/test_libmat2.py', './tests/clean.txt') | ||
| 54 | parser, mimetype = parser_factory.get_parser('./tests/data/clean.txt') | ||
| 55 | self.assertEqual(mimetype, 'text/plain') | ||
| 56 | self.assertEqual(parser, None) | ||
| 57 | os.remove('./tests/clean.txt') | ||
| 58 | |||
| 59 | |||
| 60 | class TestCorruptedFiles(unittest.TestCase): | ||
| 61 | def test_pdf(self): | ||
| 62 | shutil.copy('./tests/data/dirty.png', './tests/data/clean.png') | ||
| 63 | with self.assertRaises(ValueError): | ||
| 64 | pdf.PDFParser('./tests/data/clean.png') | ||
| 65 | os.remove('./tests/data/clean.png') | ||
| 66 | |||
| 67 | def test_png(self): | ||
| 68 | shutil.copy('./tests/data/dirty.pdf', './tests/data/clean.pdf') | ||
| 69 | with self.assertRaises(ValueError): | ||
| 70 | images.PNGParser('./tests/data/clean.pdf') | ||
| 71 | os.remove('./tests/data/clean.pdf') | ||
| 72 | |||
| 73 | def test_png2(self): | ||
| 74 | shutil.copy('./tests/test_libmat2.py', './tests/clean.png') | ||
| 75 | parser, mimetype = parser_factory.get_parser('./tests/clean.png') | ||
| 76 | self.assertIsNone(parser) | ||
| 77 | os.remove('./tests/clean.png') | ||
| 78 | |||
| 79 | def test_torrent(self): | ||
| 80 | shutil.copy('./tests/data/dirty.png', './tests/data/clean.torrent') | ||
| 81 | p = torrent.TorrentParser('./tests/data/clean.torrent') | ||
| 82 | self.assertFalse(p.remove_all()) | ||
| 83 | expected = {'Unknown meta': 'Unable to parse torrent file "./tests/data/clean.torrent".'} | ||
| 84 | self.assertEqual(p.get_meta(), expected) | ||
| 85 | |||
| 86 | with open("./tests/data/clean.torrent", "a") as f: | ||
| 87 | f.write("trailing garbage") | ||
| 88 | p = torrent.TorrentParser('./tests/data/clean.torrent') | ||
| 89 | self.assertEqual(p.get_meta(), expected) | ||
| 90 | os.remove('./tests/data/clean.torrent') | ||
| 91 | |||
| 92 | def test_odg(self): | ||
| 93 | shutil.copy('./tests/data/dirty.png', './tests/data/clean.odg') | ||
| 94 | with self.assertRaises(ValueError): | ||
| 95 | office.LibreOfficeParser('./tests/data/clean.odg') | ||
| 96 | os.remove('./tests/data/clean.odg') | ||
| 97 | |||
| 98 | def test_bmp(self): | ||
| 99 | shutil.copy('./tests/data/dirty.png', './tests/data/clean.bmp') | ||
| 100 | with self.assertRaises(ValueError): | ||
| 101 | p = images.BMPParser('./tests/data/clean.bmp') | ||
| 102 | os.remove('./tests/data/clean.bmp') | ||
| 103 | |||
| 104 | def test_docx(self): | ||
| 105 | shutil.copy('./tests/data/dirty.png', './tests/data/clean.docx') | ||
| 106 | with self.assertRaises(ValueError): | ||
| 107 | p = office.MSOfficeParser('./tests/data/clean.docx') | ||
| 108 | os.remove('./tests/data/clean.docx') | ||
| 109 | 43 | ||
| 110 | class TestGetMeta(unittest.TestCase): | 44 | class TestGetMeta(unittest.TestCase): |
| 111 | def test_pdf(self): | 45 | def test_pdf(self): |
