summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/test_climat2.py4
-rw-r--r--tests/test_policy.py31
2 files changed, 33 insertions, 2 deletions
diff --git a/tests/test_climat2.py b/tests/test_climat2.py
index 6ee84d5..9614347 100644
--- a/tests/test_climat2.py
+++ b/tests/test_climat2.py
@@ -8,13 +8,13 @@ class TestHelp(unittest.TestCase):
8 def test_help(self): 8 def test_help(self):
9 proc = subprocess.Popen(['./mat2', '--help'], stdout=subprocess.PIPE) 9 proc = subprocess.Popen(['./mat2', '--help'], stdout=subprocess.PIPE)
10 stdout, _ = proc.communicate() 10 stdout, _ = proc.communicate()
11 self.assertIn(b'usage: mat2 [-h] [-v] [-l] [-c] [-V] [-u POLICY] [-s | -L] [files [files ...]]', 11 self.assertIn(b'usage: mat2 [-h] [-v] [-l] [-c] [-V] [-u policy] [-s | -L] [files [files ...]]',
12 stdout) 12 stdout)
13 13
14 def test_no_arg(self): 14 def test_no_arg(self):
15 proc = subprocess.Popen(['./mat2'], stdout=subprocess.PIPE) 15 proc = subprocess.Popen(['./mat2'], stdout=subprocess.PIPE)
16 stdout, _ = proc.communicate() 16 stdout, _ = proc.communicate()
17 self.assertIn(b'usage: mat2 [-h] [-v] [-l] [-c] [-V] [-u POLICY] [-s | -L] [files [files ...]]', 17 self.assertIn(b'usage: mat2 [-h] [-v] [-l] [-c] [-V] [-u policy] [-s | -L] [files [files ...]]',
18 stdout) 18 stdout)
19 19
20 20
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
3import unittest
4import shutil
5import os
6
7from libmat2 import office
8
9class 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