Last active
August 29, 2015 14:22
-
-
Save jquast/038c5400535a1276430d to your computer and use it in GitHub Desktop.
./proj/tests/unit/test_pillars_yaml.py
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
""" | |
Ensure all pillar references and files are found, and parse successfully. | |
""" | |
# std imports | |
import itertools | |
import os | |
# local | |
from ..accessories import ( | |
PILLARS_TOP, | |
walk_pillar, | |
walk_sls, | |
) | |
# 3rd-party | |
import pytest | |
import salt.config | |
@pytest.mark.parametrize("path", list(walk_pillar())) | |
def test_verify_pillar(path): | |
""" | |
Verify parsing of tree of files defined by pillars/top.sls | |
""" | |
# given, exercise | |
assert os.path.exists(path) | |
contents = salt.config.load_config(path=path, env_var=None) | |
# verify | |
assert isinstance(contents, dict) | |
def test_no_duplicated_pillars(): | |
""" | |
Ensure a given pillar is only referenced once per top.sls | |
""" | |
# given | |
all_pillars = list(walk_pillar()) | |
# verify: | |
for sls in all_pillars: | |
num = all_pillars.count(sls) | |
assert 1 == num, ('file {0} referenced too many times in {1}' | |
.format(sls, PILLARS_TOP)) | |
def test_pillars_all_referenced(): | |
""" Ensure all pillar files are referenced. """ | |
all_sls = list(walk_sls(root=os.path.dirname(PILLARS_TOP))) | |
for discovered in itertools.chain(walk_pillar()): | |
assert discovered in all_sls, (discovered, all_sls) | |
all_sls.remove(discovered) | |
assert all_sls == [] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment