File: test_tmp_files.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 (54 lines) | stat: -rw-r--r-- 1,844 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
from mockdata.mock_tmp_files import (
    SystemdTempfilesOkPackage,
    SystemdTempfilesPackage,
    TempfiledPackage,
)
import pytest
from rpmlint.checks.TmpFilesCheck import TmpFilesCheck
from rpmlint.filter import Filter

from Testing import CONFIG


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


@pytest.mark.parametrize('package', [TempfiledPackage])
def test_tmpfiles(package, tmpfilescheck):
    output, test = tmpfilescheck
    test.check(package)
    out = output.print_results(output.results)

    assert 'W: pre-with-tmpfile-creation ' not in out
    assert 'W: post-without-tmpfile-creation /usr/lib/tmpfiles.d/krb5.conf' in out
    assert 'W: tmpfile-not-in-filelist /var/lib/kerberos' in out
    assert 'W: tmpfile-not-regular-file /usr/lib/tmpfiles.d/symlink.conf' in out


@pytest.mark.parametrize('package', [SystemdTempfilesPackage])
def test_tmpfiles2(package, tmpfilescheck):
    output, test = tmpfilescheck
    test.check(package)
    out = output.print_results(output.results)

    assert 'W: pre-with-tmpfile-creation /usr/lib/tmpfiles.d/systemd-tmpfiles.conf' in out
    assert 'W: post-without-tmpfile-creation' in out
    assert 'W: tmpfile-not-in-filelist /run/my_new_directory' in out
    assert 'W: tmpfile-not-regular-file' not in out


@pytest.mark.parametrize('package', [SystemdTempfilesOkPackage])
def test_tmpfiles_correct(package, tmpfilescheck):
    output, test = tmpfilescheck
    test.check(package)
    out = output.print_results(output.results)

    assert 'W: pre-with-tmpfile-creation' not in out
    assert 'W: post-without-tmpfile-creation' not in out
    assert 'W: tmpfile-not-regular-file' not in out
    assert 'W: tmpfile-not-in-filelist' not in out