|
2 | 2 |
|
3 | 3 | import sys |
4 | 4 | from importlib import resources |
| 5 | +from pathlib import Path |
5 | 6 |
|
6 | | -from _generate_package_notes import generate_section |
| 7 | +from _generate_package_notes import gather_data, generate_section |
7 | 8 |
|
8 | 9 |
|
| 10 | +class dict_dot(dict): |
| 11 | + __getattr__ = dict.get |
| 12 | + |
9 | 13 | def test_fedora_package(): |
10 | 14 | input = dict(type='rpm', name='package', version='1.2.3', architecture='noarch', osCpe='CPE') |
11 | 15 | text = '\n'.join(generate_section(input)) |
@@ -34,3 +38,17 @@ def test_fedora_long_name(): |
34 | 38 | text = '\n'.join(generate_section(input)) |
35 | 39 | expected = resources.read_text('resources', 'fedora-long-name.ld') |
36 | 40 | assert text == expected[:-1] |
| 41 | + |
| 42 | +def test_auto_cpe_system_release(): |
| 43 | + opts = dict_dot(package_type='rpm', cpe='auto', root=Path(__file__).absolute().parent / 'resources/root/') |
| 44 | + input = gather_data(opts) |
| 45 | + text = '\n'.join(generate_section(input)) |
| 46 | + expected = resources.read_text('resources', 'fedora-cpe-system-release.ld') |
| 47 | + assert text == expected[:-1] |
| 48 | + |
| 49 | +def test_auto_cpe_os_release(): |
| 50 | + opts = dict_dot(package_type='rpm', cpe='auto', root=Path(__file__).absolute().parent / 'resources/root-no-cpe/') |
| 51 | + input = gather_data(opts) |
| 52 | + text = '\n'.join(generate_section(input)) |
| 53 | + expected = resources.read_text('resources', 'fedora-cpe-os-release.ld') |
| 54 | + assert text == expected[:-1] |
0 commit comments