|
21 | 21 |
|
22 | 22 | from about_code_tool import genattrib |
23 | 23 |
|
| 24 | +from about_code_tool.tests.test_about import get_temp_file |
| 25 | + |
24 | 26 |
|
25 | 27 | TESTS_DIR = os.path.abspath(os.path.dirname(__file__)) |
26 | 28 | TESTDATA_DIR = os.path.join(TESTS_DIR, 'testdata') |
@@ -69,3 +71,29 @@ def test_component_subset_to_sublist(self): |
69 | 71 | expected = ['/tmp/', '/tmp/t1/'] |
70 | 72 | result = genattrib.component_subset_to_sublist(test) |
71 | 73 | self.assertEqual(expected, result) |
| 74 | + |
| 75 | + def test_genattrib_basic(self): |
| 76 | + about_dir = 'about_code_tool/tests/testdata/genattrib/basic/' |
| 77 | + generated_attrib = get_temp_file('generated.html') |
| 78 | + args = [about_dir, generated_attrib] |
| 79 | + options = None |
| 80 | + genattrib_command_tester(args, options) |
| 81 | + expected = open('about_code_tool/tests/testdata/genattrib/basic.html').read() |
| 82 | + result = open(generated_attrib).read() |
| 83 | + assert expected ==result |
| 84 | + |
| 85 | + def test_genattrib_from_zipped_dir(self): |
| 86 | + about_dir = 'about_code_tool/tests/testdata/genattrib/zipped_about.zip' |
| 87 | + generated_attrib = get_temp_file('generated.html') |
| 88 | + args = [about_dir, generated_attrib] |
| 89 | + options = None |
| 90 | + genattrib_command_tester(args, options) |
| 91 | + expected = open('about_code_tool/tests/testdata/genattrib/zipped_about.html').read() |
| 92 | + result = open(generated_attrib).read() |
| 93 | + assert expected ==result |
| 94 | + |
| 95 | + |
| 96 | +def genattrib_command_tester(args, options): |
| 97 | + parser = genattrib.get_parser() |
| 98 | + options, args = parser.parse_args(args, options) |
| 99 | + genattrib.main(parser, options, args) |
0 commit comments