File: test_appdata.py

package info (click to toggle)
rpmlint 2.8.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 8,308 kB
  • sloc: python: 20,622; ansic: 2,511; xml: 1,272; makefile: 17; sh: 4
file content (39 lines) | stat: -rw-r--r-- 1,301 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
from unittest.mock import patch

from mockdata.mock_appdata import AppDataPackage
import pytest
from rpmlint.checks.AppDataCheck import AppDataCheck
from rpmlint.filter import Filter

from Testing import CONFIG, HAS_APPSTREAM_GLIB


@pytest.fixture(scope='function', autouse=True)
def appdatacheck():
    CONFIG.info = True
    output = Filter(CONFIG)
    test = AppDataCheck(CONFIG, output)
    return output, test


@pytest.mark.skipif(not HAS_APPSTREAM_GLIB, reason='Optional dependency appstream-glib not installed')
@pytest.mark.parametrize('package', [AppDataPackage])
def test_appdata_fail(package, appdatacheck):
    output, test = appdatacheck
    test.check(package)
    out = output.print_results(output.results)
    # there are two borked packages
    assert len(output.results) == 2
    assert 'invalid-appdata-file' in out


@pytest.mark.parametrize('package', [AppDataPackage])
@patch('rpmlint.checks.AppDataCheck.AppDataCheck.cmd', 'command-really-not-found')
def test_appdata_fail_no_checker(package, appdatacheck):
    output, test = appdatacheck
    test.check(package)
    out = output.print_results(output.results)
    # there is just one borked file as the other is invalid content
    # but valid xml
    assert len(output.results) == 1
    assert 'invalid-appdata-file' in out