Commit 59a851389fcd8a845c0f2fde5ddf04b834b4d9d9
1 parent
4ac29b53
unittest: add simple csv file and test it
Showing
2 changed files
with
15 additions
and
1 deletions
tests/msodde/test_csv.py
| @@ -6,9 +6,10 @@ | @@ -6,9 +6,10 @@ | ||
| 6 | import unittest | 6 | import unittest |
| 7 | from tempfile import mkstemp | 7 | from tempfile import mkstemp |
| 8 | import os | 8 | import os |
| 9 | +from os.path import join | ||
| 9 | 10 | ||
| 10 | from oletools import msodde | 11 | from oletools import msodde |
| 11 | -from tests.test_utils import OutputCapture | 12 | +from tests.test_utils import OutputCapture, DATA_BASE_DIR |
| 12 | 13 | ||
| 13 | 14 | ||
| 14 | class TestCSV(unittest.TestCase): | 15 | class TestCSV(unittest.TestCase): |
| @@ -67,6 +68,18 @@ class TestCSV(unittest.TestCase): | @@ -67,6 +68,18 @@ class TestCSV(unittest.TestCase): | ||
| 67 | if self.DO_DEBUG: | 68 | if self.DO_DEBUG: |
| 68 | print('Worked: ' + desc) | 69 | print('Worked: ' + desc) |
| 69 | 70 | ||
| 71 | + def test_file(self): | ||
| 72 | + """ test simple small example file """ | ||
| 73 | + filename = join(DATA_BASE_DIR, 'msodde', 'dde-in-csv.csv') | ||
| 74 | + with OutputCapture() as capturer: | ||
| 75 | + capturer.reload_module(msodde) # re-create logger | ||
| 76 | + ret_code = msodde.main([filename, ]) | ||
| 77 | + self.assertEqual(ret_code, 0) | ||
| 78 | + links = self.get_dde_from_output(capturer) | ||
| 79 | + self.assertEqual(len(links), 1) | ||
| 80 | + self.assertEqual(links[0], | ||
| 81 | + "cmd '/k \..\..\..\Windows\System32\calc.exe'") | ||
| 82 | + | ||
| 70 | def write_and_run(self, sample_text): | 83 | def write_and_run(self, sample_text): |
| 71 | """ helper for test_texts: save text to file, run through msodde """ | 84 | """ helper for test_texts: save text to file, run through msodde """ |
| 72 | filename = None | 85 | filename = None |
tests/test-data/msodde/dde-in-csv.csv
0 → 100644
| 1 | +=cmd|'/k \..\..\..\Windows\System32\calc.exe'!A0 |