summaryrefslogtreecommitdiff
path: root/tests/test_policy.py
diff options
context:
space:
mode:
authorDaniel Kahn Gillmor2018-09-05 18:49:35 -0400
committerDaniel Kahn Gillmor2018-09-05 18:59:33 -0400
commitf3cef319b90a5a82ca879380c213651d74390a72 (patch)
treebb3018b72ab9ac60a47cd061028fae4d2d73228a /tests/test_policy.py
parent2d9ba81a84a122f09770ed53d8c8284bf3b61dc0 (diff)
Unknown Members: make policy use an Enum
Closes #60 Note: this changeset also ensures that clean.cleaned.docx is removed up after the pytest is over.
Diffstat (limited to 'tests/test_policy.py')
-rw-r--r--tests/test_policy.py11
1 files changed, 6 insertions, 5 deletions
diff --git a/tests/test_policy.py b/tests/test_policy.py
index 39282b1..5a8447b 100644
--- a/tests/test_policy.py
+++ b/tests/test_policy.py
@@ -4,28 +4,29 @@ import unittest
4import shutil 4import shutil
5import os 5import os
6 6
7from libmat2 import office 7from libmat2 import office, UnknownMemberPolicy
8 8
9class TestPolicy(unittest.TestCase): 9class TestPolicy(unittest.TestCase):
10 def test_policy_omit(self): 10 def test_policy_omit(self):
11 shutil.copy('./tests/data/embedded.docx', './tests/data/clean.docx') 11 shutil.copy('./tests/data/embedded.docx', './tests/data/clean.docx')
12 p = office.MSOfficeParser('./tests/data/clean.docx') 12 p = office.MSOfficeParser('./tests/data/clean.docx')
13 p.unknown_member_policy = 'omit' 13 p.unknown_member_policy = UnknownMemberPolicy.OMIT
14 self.assertTrue(p.remove_all()) 14 self.assertTrue(p.remove_all())
15 os.remove('./tests/data/clean.docx') 15 os.remove('./tests/data/clean.docx')
16 os.remove('./tests/data/clean.cleaned.docx')
16 17
17 def test_policy_keep(self): 18 def test_policy_keep(self):
18 shutil.copy('./tests/data/embedded.docx', './tests/data/clean.docx') 19 shutil.copy('./tests/data/embedded.docx', './tests/data/clean.docx')
19 p = office.MSOfficeParser('./tests/data/clean.docx') 20 p = office.MSOfficeParser('./tests/data/clean.docx')
20 p.unknown_member_policy = 'keep' 21 p.unknown_member_policy = UnknownMemberPolicy.KEEP
21 self.assertTrue(p.remove_all()) 22 self.assertTrue(p.remove_all())
22 os.remove('./tests/data/clean.docx') 23 os.remove('./tests/data/clean.docx')
24 os.remove('./tests/data/clean.cleaned.docx')
23 25
24 def test_policy_unknown(self): 26 def test_policy_unknown(self):
25 shutil.copy('./tests/data/embedded.docx', './tests/data/clean.docx') 27 shutil.copy('./tests/data/embedded.docx', './tests/data/clean.docx')
26 p = office.MSOfficeParser('./tests/data/clean.docx') 28 p = office.MSOfficeParser('./tests/data/clean.docx')
27 p.unknown_member_policy = 'unknown_policy_name_totally_invalid'
28 with self.assertRaises(ValueError): 29 with self.assertRaises(ValueError):
29 p.remove_all() 30 p.unknown_member_policy = UnknownMemberPolicy('unknown_policy_name_totally_invalid')
30 os.remove('./tests/data/clean.docx') 31 os.remove('./tests/data/clean.docx')
31 32