diff options
Diffstat (limited to 'test/test_menuxdg.py')
-rw-r--r-- | test/test_menuxdg.py | 79 |
1 files changed, 67 insertions, 12 deletions
diff --git a/test/test_menuxdg.py b/test/test_menuxdg.py index 36442e9..a8cabad 100644 --- a/test/test_menuxdg.py +++ b/test/test_menuxdg.py @@ -1,17 +1,72 @@ -import os +import pytest +from rpmlint.checks.MenuXDGCheck import MenuXDGCheck +from rpmlint.filter import Filter -import MenuXDGCheck -import Testing +from Testing import CONFIG, get_tested_package, HAS_DESKTOP_FILE_UTILS -class TestMenuXDGParsing(Testing.OutputTest): +@pytest.fixture(scope='function', autouse=True) +def menuxdgcheck(): + CONFIG.info = True + output = Filter(CONFIG) + test = MenuXDGCheck(CONFIG, output) + return output, test - @classmethod - def setup_class(cls): - cls.check = MenuXDGCheck.check.check - def test_raises_parse_error(self): - for package in ['menuxdg1']: - out = self._rpm_test_output(os.path.join('binary', package)) - assert 'contains parsing error' in "\n".join(out) - assert ' invalid-desktopfile ' in "\n".join(out) +@pytest.mark.skipif(not HAS_DESKTOP_FILE_UTILS, reason='Optional dependency desktop-file-utils not installed') +@pytest.mark.parametrize('package', ['binary/menuxdg1']) +def test_raises_parse_error(tmp_path, package, menuxdgcheck): + output, test = menuxdgcheck + test.check(get_tested_package(package, tmp_path)) + assert len(output.results) == 4 + out = output.print_results(output.results) + assert 'contains parsing error' in out + assert ' invalid-desktopfile ' in out + assert 'check with desktop-file-validate' in out + + +@pytest.mark.skipif(not HAS_DESKTOP_FILE_UTILS, reason='Optional dependency desktop-file-utils not installed') +@pytest.mark.parametrize('package', ['binary/desktopfile-bad-binary']) +def test_without_binary(tmp_path, package, menuxdgcheck): + output, test = menuxdgcheck + test.check(get_tested_package(package, tmp_path)) + out = output.print_results(output.results) + assert 'desktopfile-without-binary' in out + + +@pytest.mark.skipif(not HAS_DESKTOP_FILE_UTILS, reason='Optional dependency desktop-file-utils not installed') +@pytest.mark.parametrize('package', ['binary/desktopfile-bad-duplicate']) +def test_duplicate(tmp_path, package, menuxdgcheck): + output, test = menuxdgcheck + test.check(get_tested_package(package, tmp_path)) + out = output.print_results(output.results) + assert 'desktopfile-duplicate-section' in out + assert 'invalid-desktopfile' in out + + +@pytest.mark.skipif(not HAS_DESKTOP_FILE_UTILS, reason='Optional dependency desktop-file-utils not installed') +@pytest.mark.parametrize('package', ['binary/desktopfile-bad-section']) +def test_missing_header(tmp_path, package, menuxdgcheck): + output, test = menuxdgcheck + test.check(get_tested_package(package, tmp_path)) + out = output.print_results(output.results) + assert 'desktopfile-missing-header' in out + assert 'invalid-desktopfile' in out + + +@pytest.mark.skipif(not HAS_DESKTOP_FILE_UTILS, reason='Optional dependency desktop-file-utils not installed') +@pytest.mark.parametrize('package', ['binary/desktopfile-bad-unicode']) +def test_bad_unicode(tmp_path, package, menuxdgcheck): + output, test = menuxdgcheck + test.check(get_tested_package(package, tmp_path)) + out = output.print_results(output.results) + assert 'non-utf8-desktopfile' in out + + +@pytest.mark.skipif(not HAS_DESKTOP_FILE_UTILS, reason='Optional dependency desktop-file-utils not installed') +@pytest.mark.parametrize('package', ['binary/desktopfile-good']) +def test_good(tmp_path, package, menuxdgcheck): + output, test = menuxdgcheck + test.check(get_tested_package(package, tmp_path)) + out = output.print_results(output.results) + assert not out |