stages/oscap.autotailor: add json import unit test
Add a small unit test for the json tailoring file import.
This commit is contained in:
parent
4db6d4c1b4
commit
5ec5c892bf
1 changed files with 25 additions and 0 deletions
|
|
@ -51,6 +51,20 @@ def fake_input_fixture():
|
|||
}
|
||||
|
||||
|
||||
@pytest.fixture(name="fake_json_input")
|
||||
def fake_json_input_fixture():
|
||||
return {
|
||||
"name": STAGE_NAME,
|
||||
"options": {
|
||||
"filepath": "tailoring-output.xml",
|
||||
"config": {
|
||||
"datastream": "some-datastream",
|
||||
"tailoring_file": "tailoring-file.json",
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
@pytest.mark.parametrize("test_overrides,expected", TEST_INPUT)
|
||||
@patch("subprocess.run")
|
||||
def test_oscap_autotailor_overrides_smoke(mock_subprocess_run, fake_input, stage_module, test_overrides, expected):
|
||||
|
|
@ -105,3 +119,14 @@ def test_schema_validation_oscap_autotailor(fake_input, stage_schema, test_data,
|
|||
|
||||
assert res.valid is False
|
||||
testutil.assert_jsonschema_error_contains(res, expected_err, expected_num_errs=1)
|
||||
|
||||
|
||||
@patch("subprocess.run")
|
||||
def test_oscap_autotailor_json_smoke(mock_subprocess_run, fake_json_input, stage_module):
|
||||
options = fake_json_input["options"]
|
||||
stage_module.main("/some/sysroot", options)
|
||||
|
||||
assert mock_subprocess_run.call_args_list == [
|
||||
call(["/usr/bin/autotailor", "--output", "/some/sysroot/tailoring-output.xml",
|
||||
"--json-tailoring", "/some/sysroot/tailoring-file.json", "some-datastream"],
|
||||
encoding='utf8', stdout=sys.stderr, check=True)]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue