diff options
| author | jvoisin | 2018-04-23 00:24:39 +0200 |
|---|---|---|
| committer | jvoisin | 2018-04-23 00:25:06 +0200 |
| commit | 0fa184cb6fbe05ebbec9054b493e80b9a5e91683 (patch) | |
| tree | 3769b18c32e58a5a84ed53963f491f1e34acc113 | |
| parent | 73db16031b729a97ad68f27e210281535c8d4c1d (diff) | |
Test .odf support
| -rw-r--r-- | src/office.py | 3 | ||||
| -rw-r--r-- | tests/data/dirty.odf | bin | 0 -> 4861 bytes | |||
| -rw-r--r-- | tests/test_libmat2.py | 16 |
3 files changed, 17 insertions, 2 deletions
diff --git a/src/office.py b/src/office.py index 11692c3..5509c6e 100644 --- a/src/office.py +++ b/src/office.py | |||
| @@ -107,7 +107,8 @@ class LibreOfficeParser(ArchiveBasedAbstractParser): | |||
| 107 | 'application/vnd.oasis.opendocument.spreadsheet', | 107 | 'application/vnd.oasis.opendocument.spreadsheet', |
| 108 | 'application/vnd.oasis.opendocument.presentation', | 108 | 'application/vnd.oasis.opendocument.presentation', |
| 109 | 'application/vnd.oasis.opendocument.graphics', | 109 | 'application/vnd.oasis.opendocument.graphics', |
| 110 | 'application/vnd.oasis.opendocument.chart' | 110 | 'application/vnd.oasis.opendocument.chart', |
| 111 | 'application/vnd.oasis.opendocument.formula', | ||
| 111 | } | 112 | } |
| 112 | 113 | ||
| 113 | def get_meta(self): | 114 | def get_meta(self): |
diff --git a/tests/data/dirty.odf b/tests/data/dirty.odf new file mode 100644 index 0000000..49da2bc --- /dev/null +++ b/tests/data/dirty.odf | |||
| Binary files differ | |||
diff --git a/tests/test_libmat2.py b/tests/test_libmat2.py index ff5c196..6efaf31 100644 --- a/tests/test_libmat2.py +++ b/tests/test_libmat2.py | |||
| @@ -328,7 +328,6 @@ class TestCleaning(unittest.TestCase): | |||
| 328 | 328 | ||
| 329 | os.remove('./tests/data/clean.bmp') | 329 | os.remove('./tests/data/clean.bmp') |
| 330 | 330 | ||
| 331 | |||
| 332 | def test_torrent(self): | 331 | def test_torrent(self): |
| 333 | shutil.copy('./tests/data/dirty.torrent', './tests/data/clean.torrent') | 332 | shutil.copy('./tests/data/dirty.torrent', './tests/data/clean.torrent') |
| 334 | p = torrent.TorrentParser('./tests/data/clean.torrent') | 333 | p = torrent.TorrentParser('./tests/data/clean.torrent') |
| @@ -343,3 +342,18 @@ class TestCleaning(unittest.TestCase): | |||
| 343 | self.assertEqual(p.get_meta(), {}) | 342 | self.assertEqual(p.get_meta(), {}) |
| 344 | 343 | ||
| 345 | os.remove('./tests/data/clean.torrent') | 344 | os.remove('./tests/data/clean.torrent') |
| 345 | |||
| 346 | def test_odf(self): | ||
| 347 | shutil.copy('./tests/data/dirty.odf', './tests/data/clean.odf') | ||
| 348 | p = office.LibreOfficeParser('./tests/data/clean.odf') | ||
| 349 | |||
| 350 | meta = p.get_meta() | ||
| 351 | self.assertEqual(meta['meta:creation-date'], '2018-04-23T00:18:59.438231281') | ||
| 352 | |||
| 353 | ret = p.remove_all() | ||
| 354 | self.assertTrue(ret) | ||
| 355 | |||
| 356 | p = office.LibreOfficeParser('./tests/data/clean.odf.cleaned') | ||
| 357 | self.assertEqual(p.get_meta(), {}) | ||
| 358 | |||
| 359 | os.remove('./tests/data/clean.odf') | ||
