"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "tests/unit/utils/test_thin.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_thin.py  (salt-3002.1):test_thin.py  (salt-3002.2)
skipping to change at line 1143 skipping to change at line 1143
os.path.join("msgpack", "__init__.py"), os.path.join("msgpack", "__init__.py"),
] ]
) )
patch_which = patch("salt.utils.path.which", return_value=True) patch_which = patch("salt.utils.path.which", return_value=True)
with patch_os, patch_proc, patch_which: with patch_os, patch_proc, patch_which:
thin._pack_alternative(ext_conf, self.digest, self.tar) thin._pack_alternative(ext_conf, self.digest, self.tar)
calls = self.tar.mock_calls calls = self.tar.mock_calls
for _file in exp_files: for _file in exp_files:
assert [x for x in calls if "{}".format(_file) in x.args] assert [x for x in calls if "{}".format(_file) in x[-2]]
def test_pack_alternatives(self): def test_pack_alternatives(self):
""" """
test thin._pack_alternatives test thin._pack_alternatives
""" """
with patch("salt.utils.thin.get_ext_tops", MagicMock(return_value=self.t ops)): with patch("salt.utils.thin.get_ext_tops", MagicMock(return_value=self.t ops)):
thin._pack_alternative(self.ext_conf, self.digest, self.tar) thin._pack_alternative(self.ext_conf, self.digest, self.tar)
calls = self.tar.mock_calls calls = self.tar.mock_calls
for _file in self.exp_files: for _file in self.exp_files:
assert [x for x in calls if "{}".format(_file) in x.args] assert [x for x in calls if "{}".format(_file) in x[-2]]
assert [ assert [
x x
for x in calls for x in calls
if os.path.join("test", "pyall", _file) in x.kwargs["arcname "] if os.path.join("test", "pyall", _file) in x[-1]["arcname"]
] ]
def test_pack_alternatives_not_normalized(self): def test_pack_alternatives_not_normalized(self):
""" """
test thin._pack_alternatives when the path test thin._pack_alternatives when the path
is not normalized is not normalized
""" """
tops = copy.deepcopy(self.tops) tops = copy.deepcopy(self.tops)
tops["test"]["dependencies"] = [self.jinja_fp + "/"] tops["test"]["dependencies"] = [self.jinja_fp + "/"]
with patch("salt.utils.thin.get_ext_tops", MagicMock(return_value=tops)) : with patch("salt.utils.thin.get_ext_tops", MagicMock(return_value=tops)) :
thin._pack_alternative(self.ext_conf, self.digest, self.tar) thin._pack_alternative(self.ext_conf, self.digest, self.tar)
calls = self.tar.mock_calls calls = self.tar.mock_calls
for _file in self.exp_files: for _file in self.exp_files:
assert [x for x in calls if "{}".format(_file) in x.args] assert [x for x in calls if "{}".format(_file) in x[-2]]
assert [ assert [
x x
for x in calls for x in calls
if os.path.join("test", "pyall", _file) in x.kwargs["arcname "] if os.path.join("test", "pyall", _file) in x[-1]["arcname"]
] ]
def test_pack_alternatives_path_doesnot_exist(self): def test_pack_alternatives_path_doesnot_exist(self):
""" """
test thin._pack_alternatives when the path test thin._pack_alternatives when the path
doesnt exist. Check error log message doesnt exist. Check error log message
and expect that because the directory and expect that because the directory
does not exist jinja2 does not get does not exist jinja2 does not get
added to the tar added to the tar
""" """
skipping to change at line 1198 skipping to change at line 1198
tops["test"]["dependencies"] = [bad_path] tops["test"]["dependencies"] = [bad_path]
with patch("salt.utils.thin.get_ext_tops", MagicMock(return_value=tops)) : with patch("salt.utils.thin.get_ext_tops", MagicMock(return_value=tops)) :
with TstSuiteLoggingHandler() as log_handler: with TstSuiteLoggingHandler() as log_handler:
thin._pack_alternative(self.ext_conf, self.digest, self.tar) thin._pack_alternative(self.ext_conf, self.digest, self.tar)
msg = "ERROR:File path {} does not exist. Unable to add to salt- ssh thin".format( msg = "ERROR:File path {} does not exist. Unable to add to salt- ssh thin".format(
bad_path bad_path
) )
assert msg in log_handler.messages assert msg in log_handler.messages
calls = self.tar.mock_calls calls = self.tar.mock_calls
for _file in self.exp_files: for _file in self.exp_files:
arg = [x for x in calls if "{}".format(_file) in x.args] arg = [x for x in calls if "{}".format(_file) in x[-2]]
kwargs = [ kwargs = [
x x
for x in calls for x in calls
if os.path.join("test", "pyall", _file) in x.kwargs["arcname"] if os.path.join("test", "pyall", _file) in x[-1]["arcname"]
] ]
if "jinja2" in _file: if "jinja2" in _file:
assert not arg assert not arg
assert not kwargs assert not kwargs
else: else:
assert arg assert arg
assert kwargs assert kwargs
def test_pack_alternatives_auto_detect(self): def test_pack_alternatives_auto_detect(self):
""" """
skipping to change at line 1240 skipping to change at line 1240
[ [
os.path.join("yaml", "__init__.py"), os.path.join("yaml", "__init__.py"),
os.path.join("tornado", "__init__.py"), os.path.join("tornado", "__init__.py"),
os.path.join("msgpack", "__init__.py"), os.path.join("msgpack", "__init__.py"),
] ]
) )
with patch_tops_py: with patch_tops_py:
thin._pack_alternative(ext_conf, self.digest, self.tar) thin._pack_alternative(ext_conf, self.digest, self.tar)
calls = self.tar.mock_calls calls = self.tar.mock_calls
for _file in exp_files: for _file in exp_files:
assert [x for x in calls if "{}".format(_file) in x.args] assert [x for x in calls if "{}".format(_file) in x[-2]]
def test_pack_alternatives_empty_dependencies(self): def test_pack_alternatives_empty_dependencies(self):
""" """
test _pack_alternatives when dependencies is not test _pack_alternatives when dependencies is not
set in the config. set in the config.
""" """
ext_conf = copy.deepcopy(self.ext_conf) ext_conf = copy.deepcopy(self.ext_conf)
ext_conf["test"]["auto_detect"] = True ext_conf["test"]["auto_detect"] = True
ext_conf["test"].pop("dependencies") ext_conf["test"].pop("dependencies")
skipping to change at line 1272 skipping to change at line 1272
[ [
os.path.join("yaml", "__init__.py"), os.path.join("yaml", "__init__.py"),
os.path.join("tornado", "__init__.py"), os.path.join("tornado", "__init__.py"),
os.path.join("msgpack", "__init__.py"), os.path.join("msgpack", "__init__.py"),
] ]
) )
with patch_tops_py: with patch_tops_py:
thin._pack_alternative(ext_conf, self.digest, self.tar) thin._pack_alternative(ext_conf, self.digest, self.tar)
calls = self.tar.mock_calls calls = self.tar.mock_calls
for _file in exp_files: for _file in exp_files:
assert [x for x in calls if "{}".format(_file) in x.args] assert [x for x in calls if "{}".format(_file) in x[-2]]
@skipIf( @skipIf(
salt.utils.platform.is_windows(), "salt-ssh does not deploy to/from wind ows" salt.utils.platform.is_windows(), "salt-ssh does not deploy to/from wind ows"
) )
def test_thin_dir(self): def test_thin_dir(self):
""" """
Test the thin dir to make sure salt-call can run Test the thin dir to make sure salt-call can run
Run salt call via a python in a new virtual environment to ensure Run salt call via a python in a new virtual environment to ensure
salt-call has all dependencies needed. salt-call has all dependencies needed.
 End of changes. 9 change blocks. 
9 lines changed or deleted 9 lines changed or added

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