diff options
| author | jvoisin | 2018-09-05 17:22:17 +0200 |
|---|---|---|
| committer | jvoisin | 2018-09-05 17:26:09 +0200 |
| commit | 46bb1b83ea0843c25783f86e2033a10aeaed79d2 (patch) | |
| tree | 3446382de51c0a861f4158f6be9e65bcf94b06ad /tests/test_policy.py | |
| parent | 1d7e374e5b0c6a84b3319d9d1e7c6f5c222af878 (diff) | |
Improve the previous commit
Diffstat (limited to 'tests/test_policy.py')
| -rw-r--r-- | tests/test_policy.py | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/test_policy.py b/tests/test_policy.py new file mode 100644 index 0000000..39282b1 --- /dev/null +++ b/tests/test_policy.py | |||
| @@ -0,0 +1,31 @@ | |||
| 1 | #!/usr/bin/python3 | ||
| 2 | |||
| 3 | import unittest | ||
| 4 | import shutil | ||
| 5 | import os | ||
| 6 | |||
| 7 | from libmat2 import office | ||
| 8 | |||
| 9 | class TestPolicy(unittest.TestCase): | ||
| 10 | def test_policy_omit(self): | ||
| 11 | shutil.copy('./tests/data/embedded.docx', './tests/data/clean.docx') | ||
| 12 | p = office.MSOfficeParser('./tests/data/clean.docx') | ||
| 13 | p.unknown_member_policy = 'omit' | ||
| 14 | self.assertTrue(p.remove_all()) | ||
| 15 | os.remove('./tests/data/clean.docx') | ||
| 16 | |||
| 17 | def test_policy_keep(self): | ||
| 18 | shutil.copy('./tests/data/embedded.docx', './tests/data/clean.docx') | ||
| 19 | p = office.MSOfficeParser('./tests/data/clean.docx') | ||
| 20 | p.unknown_member_policy = 'keep' | ||
| 21 | self.assertTrue(p.remove_all()) | ||
| 22 | os.remove('./tests/data/clean.docx') | ||
| 23 | |||
| 24 | def test_policy_unknown(self): | ||
| 25 | shutil.copy('./tests/data/embedded.docx', './tests/data/clean.docx') | ||
| 26 | p = office.MSOfficeParser('./tests/data/clean.docx') | ||
| 27 | p.unknown_member_policy = 'unknown_policy_name_totally_invalid' | ||
| 28 | with self.assertRaises(ValueError): | ||
| 29 | p.remove_all() | ||
| 30 | os.remove('./tests/data/clean.docx') | ||
| 31 | |||
