File: test_generate_most_used_rules.py

package info (click to toggle)
scap-security-guide 0.1.78-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 114,600 kB
  • sloc: xml: 245,305; sh: 84,381; python: 33,093; makefile: 27
file content (23 lines) | stat: -rw-r--r-- 681 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
import os
import sys
import pytest
from argparse import Namespace
from utils.profile_tool import command_most_used_rules

DATA_DIR = os.path.abspath(
    os.path.join(os.path.dirname(__file__), "..", "ssg-module", "data")
)
DATA_STREAM_PATH = os.path.join(DATA_DIR, "simple_data_stream.xml")


def get_fake_args():
    return Namespace(
        subcommand="most-used-rules", BENCHMARKS=[str(DATA_STREAM_PATH)], format="plain"
    )


@pytest.mark.skipif(sys.version_info[0] < 3, reason="requires python3")
def test_command(capsys):
    command_most_used_rules(get_fake_args())
    captured = capsys.readouterr()
    assert "xccdf_com.example.www_rule_test-pass: 1" in captured.out