Passed
Pull Request — rhel8-branch (#148)
by Matěj
02:13
created

test_content_handling   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 1
eloc 27
dl 0
loc 35
rs 10
c 0
b 0
f 0

1 Function

Rating   Name   Duplication   Size   Complexity  
A test_identify_files() 0 12 1
1
import os
2
import glob
3
4
import pytest
5
6
from org_fedora_oscap import content_handling as ch
7
8
9
TESTING_FILES_PATH = os.path.join(
10
    os.path.dirname(__file__), os.path.pardir, "testing_files")
11
DS_FILEPATH = os.path.join(
12
    TESTING_FILES_PATH, "testing_ds.xml")
13
14
DS_IDS = "scap_org.open-scap_datastream_tst"
15
CHK_FIRST_ID = "scap_org.open-scap_cref_first-xccdf.xml"
16
CHK_SECOND_ID = "scap_org.open-scap_cref_second-xccdf.xml"
17
18
PROFILE1_ID = "xccdf_com.example_profile_my_profile"
19
PROFILE2_ID = "xccdf_com.example_profile_my_profile2"
20
PROFILE3_ID = "xccdf_com.example_profile_my_profile3"
21
22
23
def test_identify_files():
24
    filenames = glob.glob(TESTING_FILES_PATH + "/*")
25
    identified = ch.identify_files(filenames)
26
    assert identified[DS_FILEPATH] == ch.CONTENT_TYPES["DATASTREAM"]
27
    assert identified[
28
        os.path.join(TESTING_FILES_PATH, "scap-mycheck-oval.xml")] == ch.CONTENT_TYPES["OVAL"]
29
    assert identified[
30
        os.path.join(TESTING_FILES_PATH, "tailoring.xml")] == ch.CONTENT_TYPES["TAILORING"]
31
    assert identified[
32
        os.path.join(TESTING_FILES_PATH, "testing_xccdf.xml")] == ch.CONTENT_TYPES["XCCDF_CHECKLIST"]
33
    assert identified[
34
        os.path.join(TESTING_FILES_PATH, "cpe-dict.xml")] == ch.CONTENT_TYPES["CPE_DICT"]
35