"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "tests/unit/pillar/test_file_tree.py" between
salt-3002.1.tar.gz and salt-3002.2.tar.gz

About: SaltStack is a systems management software for data center automation, cloud orchestration, server provisioning, configuration management and more. Community version.

test_file_tree.py  (salt-3002.1):test_file_tree.py  (salt-3002.2)
# -*- coding: utf-8 -*-
""" """
test for pillar file_tree.py test for pillar file_tree.py
""" """
# Import python libs
from __future__ import absolute_import, print_function, unicode_literals
import os import os
import shutil import shutil
import tempfile import tempfile
import salt.pillar.file_tree as file_tree import salt.pillar.file_tree as file_tree
# Import Salt Libs
import salt.utils.files import salt.utils.files
import salt.utils.stringutils import salt.utils.stringutils
from tests.support.helpers import TstSuiteLoggingHandler from tests.support.helpers import TstSuiteLoggingHandler
from tests.support.mixins import LoaderModuleMockMixin from tests.support.mixins import LoaderModuleMockMixin
from tests.support.mock import MagicMock, patch from tests.support.mock import MagicMock, patch
# Import Salt Testing libs
from tests.support.runtests import RUNTIME_VARS from tests.support.runtests import RUNTIME_VARS
from tests.support.unit import TestCase from tests.support.unit import TestCase
MINION_ID = "test-host" MINION_ID = "test-host"
NODEGROUP_PATH = os.path.join("nodegroups", "test-group", "files") NODEGROUP_PATH = os.path.join("nodegroups", "test-group", "files")
HOST_PATH = os.path.join("hosts", MINION_ID, "files") HOST_PATH = os.path.join("hosts", MINION_ID, "files")
BASE_PILLAR_CONTENT = {"files": {"hostfile": b"base", "groupfile": b"base"}} BASE_PILLAR_CONTENT = {"files": {"hostfile": b"base", "groupfile": b"base"}}
DEV_PILLAR_CONTENT = { DEV_PILLAR_CONTENT = {
"files": { "files": {
skipping to change at line 161 skipping to change at line 153
self.assertEqual({}, mypillar) self.assertEqual({}, mypillar)
for message in handler.messages: for message in handler.messages:
if ( if (
message.startswith("ERROR:") message.startswith("ERROR:")
and "pillarenv is not set" in message and "pillarenv is not set" in message
): ):
break break
else: else:
raise AssertionError("Did not find error message") raise AssertionError("Did not find error message")
def test_file_tree_bytes(self):
"""
test file_tree pillar returns bytes
"""
absolute_path = os.path.join(self.pillar_path, "base")
with patch(
"salt.utils.minions.CkMinions.check_minions",
MagicMock(return_value=_CHECK_MINIONS_RETURN),
):
mypillar = file_tree.ext_pillar(MINION_ID, None, absolute_path)
self.assertEqual(BASE_PILLAR_CONTENT, mypillar)
with patch.dict(file_tree.__opts__, {"pillarenv": "dev"}):
mypillar = file_tree.ext_pillar(MINION_ID, None, absolute_path)
self.assertEqual(mypillar["files"]["groupfile"], b"base")
 End of changes. 5 change blocks. 
8 lines changed or deleted 0 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)