-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
73 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,44 @@ | ||
import os | ||
|
||
import yaml | ||
import pytest | ||
|
||
from jsonschema.exceptions import ValidationError | ||
from ubiconfig.utils import config_validation | ||
|
||
TEST_DATA = os.path.join(os.path.dirname(__file__), | ||
'../../data/configs/dnf7/rhel-atomic-host.yaml') | ||
|
||
|
||
def test_validate_data(): | ||
@pytest.fixture | ||
def dnf7_config(): | ||
with open(TEST_DATA) as f: | ||
config = yaml.safe_load(f) | ||
assert config_validation.validate_config(config) is None | ||
return config | ||
|
||
|
||
def test_validate_data_pass(dnf7_config): | ||
assert config_validation.validate_config(dnf7_config) is None | ||
|
||
|
||
def test_validate_data_pass_without_module(dnf7_config): | ||
dnf7_config.pop('modules') | ||
assert config_validation.validate_config(dnf7_config) is None | ||
|
||
|
||
def test_validate_failed_missing_content_sets(dnf7_config): | ||
dnf7_config.pop('content_sets') | ||
with pytest.raises(ValidationError): | ||
config_validation.validate_config(dnf7_config) | ||
|
||
|
||
def test_validate_failed_extra_keyword(dnf7_config): | ||
dnf7_config.update({'extra': 'something should not exist'}) | ||
with pytest.raises(ValidationError): | ||
config_validation.validate_config(dnf7_config) | ||
|
||
|
||
def test_validate_failed_missing_package_include(dnf7_config): | ||
dnf7_config['packages'].pop('include') | ||
with pytest.raises(ValidationError): | ||
config_validation.validate_config(dnf7_config) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters