Commit 6b7f2674cd68925ad82f0db082aeb28e7a54fe45

Authored by Christian Herdtweck
1 parent e250400b

tests: call more top-level function from msodde

Showing 1 changed file with 21 additions and 14 deletions
tests/msodde/test_basic.py
... ... @@ -94,24 +94,27 @@ class TestDdeLinks(unittest.TestCase):
94 94 def test_with_dde(self):
95 95 """ check that dde links appear on stdout """
96 96 filename = 'dde-test-from-office2003.doc'
97   - output = msodde.process_file(
98   - join(BASE_DIR, 'msodde', filename), msodde.FIELD_FILTER_BLACKLIST)
  97 + output = msodde.process_maybe_encrypted(
  98 + join(BASE_DIR, 'msodde', filename),
  99 + field_filter_mode=msodde.FIELD_FILTER_BLACKLIST)
99 100 self.assertNotEqual(len(self.get_dde_from_output(output)), 0,
100 101 msg='Found no dde links in output of ' + filename)
101 102  
102 103 def test_no_dde(self):
103 104 """ check that no dde links appear on stdout """
104 105 filename = 'harmless-clean.doc'
105   - output = msodde.process_file(
106   - join(BASE_DIR, 'msodde', filename), msodde.FIELD_FILTER_BLACKLIST)
  106 + output = msodde.process_maybe_encrypted(
  107 + join(BASE_DIR, 'msodde', filename),
  108 + field_filter_mode=msodde.FIELD_FILTER_BLACKLIST)
107 109 self.assertEqual(len(self.get_dde_from_output(output)), 0,
108 110 msg='Found dde links in output of ' + filename)
109 111  
110 112 def test_with_dde_utf16le(self):
111 113 """ check that dde links appear on stdout """
112 114 filename = 'dde-test-from-office2013-utf_16le-korean.doc'
113   - output = msodde.process_file(
114   - join(BASE_DIR, 'msodde', filename), msodde.FIELD_FILTER_BLACKLIST)
  115 + output = msodde.process_maybe_encrypted(
  116 + join(BASE_DIR, 'msodde', filename),
  117 + field_filter_mode=msodde.FIELD_FILTER_BLACKLIST)
115 118 self.assertNotEqual(len(self.get_dde_from_output(output)), 0,
116 119 msg='Found no dde links in output of ' + filename)
117 120  
... ... @@ -119,8 +122,9 @@ class TestDdeLinks(unittest.TestCase):
119 122 """ check that dde links are found in excel 2007+ files """
120 123 expect = ['cmd /c calc.exe', ]
121 124 for extn in 'xlsx', 'xlsm', 'xlsb':
122   - output = msodde.process_file(
123   - join(BASE_DIR, 'msodde', 'dde-test.' + extn), msodde.FIELD_FILTER_BLACKLIST)
  125 + output = msodde.process_maybe_encrypted(
  126 + join(BASE_DIR, 'msodde', 'dde-test.' + extn),
  127 + field_filter_mode=msodde.FIELD_FILTER_BLACKLIST)
124 128  
125 129 self.assertEqual(expect, self.get_dde_from_output(output),
126 130 msg='unexpected output for dde-test.{0}: {1}'
... ... @@ -130,8 +134,9 @@ class TestDdeLinks(unittest.TestCase):
130 134 """ check that dde in xml from word / excel is found """
131 135 for name_part in 'excel2003', 'word2003', 'word2007':
132 136 filename = 'dde-in-' + name_part + '.xml'
133   - output = msodde.process_file(
134   - join(BASE_DIR, 'msodde', filename), msodde.FIELD_FILTER_BLACKLIST)
  137 + output = msodde.process_maybe_encrypted(
  138 + join(BASE_DIR, 'msodde', filename),
  139 + field_filter_mode=msodde.FIELD_FILTER_BLACKLIST)
135 140 links = self.get_dde_from_output(output)
136 141 self.assertEqual(len(links), 1, 'found {0} dde-links in {1}'
137 142 .format(len(links), filename))
... ... @@ -143,15 +148,17 @@ class TestDdeLinks(unittest.TestCase):
143 148 def test_clean_rtf_blacklist(self):
144 149 """ find a lot of hyperlinks in rtf spec """
145 150 filename = 'RTF-Spec-1.7.rtf'
146   - output = msodde.process_file(
147   - join(BASE_DIR, 'msodde', filename), msodde.FIELD_FILTER_BLACKLIST)
  151 + output = msodde.process_maybe_encrypted(
  152 + join(BASE_DIR, 'msodde', filename),
  153 + field_filter_mode=msodde.FIELD_FILTER_BLACKLIST)
148 154 self.assertEqual(len(self.get_dde_from_output(output)), 1413)
149 155  
150 156 def test_clean_rtf_ddeonly(self):
151 157 """ find no dde links in rtf spec """
152 158 filename = 'RTF-Spec-1.7.rtf'
153   - output = msodde.process_file(
154   - join(BASE_DIR, 'msodde', filename), msodde.FIELD_FILTER_DDE)
  159 + output = msodde.process_maybe_encrypted(
  160 + join(BASE_DIR, 'msodde', filename),
  161 + field_filter_mode=msodde.FIELD_FILTER_DDE)
155 162 self.assertEqual(len(self.get_dde_from_output(output)), 0,
156 163 msg='Found dde links in output of ' + filename)
157 164  
... ...