Commit faeb2aedbfab884a1e150d057f4099e95a3a213e
1 parent
5609051f
unittest: create tests for ppt_record_parser.is_ppt
Showing
2 changed files
with
37 additions
and
0 deletions
tests/ppt_parser/__init__.py
0 → 100644
tests/ppt_parser/test_basic.py
0 → 100644
| 1 | +""" Test ppt_parser and ppt_record_parser """ | |
| 2 | + | |
| 3 | +import unittest | |
| 4 | +import os | |
| 5 | +from os.path import join | |
| 6 | + | |
| 7 | +# Directory with test data, independent of current working directory | |
| 8 | +from tests.test_utils import DATA_BASE_DIR | |
| 9 | + | |
| 10 | +from oletools import ppt_record_parser | |
| 11 | +# ppt_parser not tested yet | |
| 12 | + | |
| 13 | + | |
| 14 | +class TestBasic(unittest.TestCase): | |
| 15 | + """ test basic functionality of ppt parsing """ | |
| 16 | + | |
| 17 | + def test_is_ppt(self): | |
| 18 | + """ test ppt_record_parser.is_ppt(filename) """ | |
| 19 | + exceptions = [] | |
| 20 | + for base_dir, _, files in os.walk(DATA_BASE_DIR): | |
| 21 | + for filename in files: | |
| 22 | + if filename in exceptions: | |
| 23 | + continue | |
| 24 | + full_name = join(base_dir, filename) | |
| 25 | + if filename.endswith('.ppt') or filename.endswith('.pps'): | |
| 26 | + self.assertTrue(ppt_record_parser.is_ppt(full_name), | |
| 27 | + msg='{0} not recognized as ppt file' | |
| 28 | + .format(full_name)) | |
| 29 | + else: | |
| 30 | + self.assertFalse(ppt_record_parser.is_ppt(full_name), | |
| 31 | + msg='{0} erroneously recognized as ppt' | |
| 32 | + .format(full_name)) | |
| 33 | + | |
| 34 | + | |
| 35 | +# just in case somebody calls this file as a script | |
| 36 | +if __name__ == '__main__': | |
| 37 | + unittest.main() | ... | ... |