diff options
| author | jvoisin | 2018-07-30 22:36:36 +0200 |
|---|---|---|
| committer | jvoisin | 2018-07-30 22:36:36 +0200 |
| commit | a1257c538be63f1c8119e4e2f9116dccfd91d8b7 (patch) | |
| tree | c5273751bb8132560335a17a0b64c0c1da472b6a | |
| parent | 6d8e999f124601e4331c8f965d50f8edc58b13af (diff) | |
Add some tests about pathological files
| -rw-r--r-- | tests/test_corrupted_files.py | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/tests/test_corrupted_files.py b/tests/test_corrupted_files.py index 20b1efa..928ca1f 100644 --- a/tests/test_corrupted_files.py +++ b/tests/test_corrupted_files.py | |||
| @@ -7,6 +7,41 @@ import os | |||
| 7 | from libmat2 import pdf, images, audio, office, parser_factory, torrent, harmless | 7 | from libmat2 import pdf, images, audio, office, parser_factory, torrent, harmless |
| 8 | 8 | ||
| 9 | 9 | ||
| 10 | class TestInexistentFiles(unittest.TestCase): | ||
| 11 | def test_ro(self): | ||
| 12 | parser, mimetype = parser_factory.get_parser('/etc/passwd') | ||
| 13 | self.assertEqual(mimetype, None) | ||
| 14 | self.assertEqual(parser, None) | ||
| 15 | |||
| 16 | def test_notaccessible(self): | ||
| 17 | parser, mimetype = parser_factory.get_parser('/etc/shadow') | ||
| 18 | self.assertEqual(mimetype, None) | ||
| 19 | self.assertEqual(parser, None) | ||
| 20 | |||
| 21 | def test_folder(self): | ||
| 22 | parser, mimetype = parser_factory.get_parser('./tests/') | ||
| 23 | self.assertEqual(mimetype, None) | ||
| 24 | self.assertEqual(parser, None) | ||
| 25 | |||
| 26 | def test_inexistingfile(self): | ||
| 27 | parser, mimetype = parser_factory.get_parser('./tests/NONEXISTING_FILE') | ||
| 28 | self.assertEqual(mimetype, None) | ||
| 29 | self.assertEqual(parser, None) | ||
| 30 | |||
| 31 | def test_chardevice(self): | ||
| 32 | parser, mimetype = parser_factory.get_parser('/dev/zero') | ||
| 33 | self.assertEqual(mimetype, None) | ||
| 34 | self.assertEqual(parser, None) | ||
| 35 | |||
| 36 | def test_brokensymlink(self): | ||
| 37 | shutil.copy('./tests/test_libmat2.py', './tests/clean.py') | ||
| 38 | os.symlink('./tests/clean.py', './tests/SYMLINK') | ||
| 39 | os.remove('./tests/clean.py') | ||
| 40 | parser, mimetype = parser_factory.get_parser('./tests/SYMLINK') | ||
| 41 | self.assertEqual(mimetype, None) | ||
| 42 | self.assertEqual(parser, None) | ||
| 43 | os.unlink('./tests/SYMLINK') | ||
| 44 | |||
| 10 | class TestUnsupportedFiles(unittest.TestCase): | 45 | class TestUnsupportedFiles(unittest.TestCase): |
| 11 | def test_pdf(self): | 46 | def test_pdf(self): |
| 12 | shutil.copy('./tests/test_libmat2.py', './tests/clean.py') | 47 | shutil.copy('./tests/test_libmat2.py', './tests/clean.py') |
