File: test_assert_reference_unique.py

package info (click to toggle)
scap-security-guide 0.1.76-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 110,644 kB
  • sloc: xml: 241,883; sh: 73,777; python: 32,527; makefile: 27
file content (62 lines) | stat: -rwxr-xr-x 1,633 bytes parent folder | download
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
55
56
57
58
59
60
61
62
import os
import pytest
import subprocess
import sys

if sys.version_info < (3, 0):
    try:
        # pytest v4.6 has allow_module_level
        pytest.skip("requires python3", allow_module_level=True)
    except TypeError:
        # older pytest v2.7 does not have it and it is implied
        pytest.skip("requires python3")

DATADIR = os.path.abspath(os.path.join(os.path.dirname(__file__), "data"))
CMD = os.path.abspath(
    os.path.join(os.path.dirname(__file__), "..", "..", "assert_reference_unique.py")
)


def test_assert_reference_unique_noop():
    p = subprocess.run(
        [CMD],
        stdout=subprocess.DEVNULL,
        stderr=subprocess.DEVNULL,
    )
    assert p.returncode == 2


def test_assert_reference_unique_help():
    p = subprocess.run(
        [CMD, "--help"],
        stdout=subprocess.DEVNULL,
        stderr=subprocess.DEVNULL,
    )
    assert p.returncode == 0


def test_assert_reference_unique_nonexisting():
    p = subprocess.run(
        [CMD, os.path.join(DATADIR, "rule_reference_nonexisting"), "foo"],
        stdout=subprocess.DEVNULL,
        stderr=subprocess.DEVNULL,
    )
    assert p.returncode == 7


def test_assert_reference_unique_pass():
    p = subprocess.run(
        [CMD, os.path.join(DATADIR, "rule_reference_pass"), "foo"],
        stdout=subprocess.DEVNULL,
        stderr=subprocess.DEVNULL,
    )
    assert p.returncode == 0


def test_assert_reference_unique_fail():
    p = subprocess.run(
        [CMD, os.path.join(DATADIR, "rule_reference_fail"), "foo"],
        stdout=subprocess.DEVNULL,
        stderr=subprocess.DEVNULL,
    )
    assert p.returncode == 1