mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 01:18:58 +00:00
20ed2c6bcf
* salt/cloud/__init__.py: remove repr formatting * salt/cloud/clouds/azurearm.py: remove repr formatting * salt/cloud/clouds/ec2.py: remove repr formatting * salt/cloud/clouds/profitbricks.py: remove repr formatting * salt/loader.py: remove repr formatting * salt/modules/win_file.py: remove repr formatting * salt/modules/zypper.py: remove repr formatting * salt/pillar/consul_pillar.py: remove repr formatting * salt/renderers/pyobjects.py: remove repr formatting * salt/returners/sentry_return.py: remove repr formatting * salt/states/bower.py: remove repr formatting * salt/states/cabal.py: remove repr formatting * salt/states/cmd.py: remove repr formatting * salt/states/composer.py: remove repr formatting * salt/states/win_network.py: remove repr formatting * salt/states/eselect.py: remove repr formatting * salt/states/file.py: remove repr formatting * salt/states/htpasswd.py: remove repr formatting * salt/states/memcached.py: remove repr formatting * salt/states/npm.py: remove repr formatting * salt/states/pip_state.py: remove repr formatting * salt/states/pkg.py: remove repr formatting * salt/states/pkgrepo.py: remove repr formatting * salt/states/supervisord.py: remove repr formatting * salt/states/timezone.py: remove repr formatting * salt/states/virtualenv_mod.py: remove repr formatting * salt/states/dockerio.py: remove repr formatting * salt/states/win_system.py: remove repr formatting * salt/utils/nb_popen.py: remove repr formatting * salt/utils/cloud.py: remove repr formatting * Add pylint disable due to legit usage of repr flag See https://github.com/saltstack/salt-pylint/pull/6 * Fix composer tests These tests needed to be updated because quoting was changed in the state module in 9dc9146. There was an unnecessary !r used for the exception class there, which means that instead of the exception class being passed through the formatter and coming out with the equivalent value of err.__str__(), we get a repr'ed instance of the exception class (i.e. SaltException('',)) in the state output. The unit test was asserting that we have that repr'ed instance of SaltException in the output, a case of writing the test to confirm the badly-conceived output in the state. This has also been corrected. * salt/cloud/clouds/azurearm.py: lint fixes * salt/modules/boto_s3_bucket.py: lint fixes * salt/modules/minion.py: lint fixes * salt/modules/reg.py: lint fixes * salt/modules/testinframod.py: lint fixes * salt/modules/win_iis.py: lint fixes * salt/pillar/csvpillar.py: lint fixes * salt/utils/win_functions.py: lint fixes * salt/states/nxos.py: lint fixes * salt/returners/mongo_future_return.py: lint fixes * tests/integration/__init__.py: lint fixes * tests/unit/context_test.py: lint fixes * tests/integration/states/file.py: lint fixes * tests/integration/utils/test_reactor.py: lint fixes * tests/integration/utils/testprogram.py: lint fixes * tests/unit/__init__.py: lint fixes * tests/integration/shell/minion.py: lint fixes * tests/unit/modules/boto_apigateway_test.py: lint fixes * tests/unit/modules/boto_cognitoidentity_test.py: lint fixes * tests/unit/modules/boto_elasticsearch_domain_test.py: lint fixes * tests/unit/modules/k8s_test.py: lint fixes * tests/unit/modules/reg_win_test.py: lint fixes * tests/unit/states/boto_apigateway_test.py: lint fixes * tests/unit/states/boto_cognitoidentity_test.py: lint fixes * tests/unit/states/boto_elasticsearch_domain_test.py: lint fixes
117 lines
4.3 KiB
Python
117 lines
4.3 KiB
Python
# -*- coding: utf-8 -*-
|
|
'''
|
|
:codeauthor: :email:`Jayesh Kariya <jayeshk@saltstack.com>`
|
|
'''
|
|
# Import Python libs
|
|
from __future__ import absolute_import
|
|
|
|
# Import Salt Testing Libs
|
|
from salttesting import skipIf, TestCase
|
|
from salttesting.mock import (
|
|
NO_MOCK,
|
|
NO_MOCK_REASON,
|
|
MagicMock,
|
|
patch)
|
|
|
|
from salttesting.helpers import ensure_in_syspath
|
|
from salt.exceptions import SaltException
|
|
|
|
ensure_in_syspath('../../')
|
|
|
|
# Import Salt Libs
|
|
from salt.states import composer
|
|
|
|
composer.__salt__ = {}
|
|
composer.__opts__ = {}
|
|
|
|
|
|
@skipIf(NO_MOCK, NO_MOCK_REASON)
|
|
class ComposerTestCase(TestCase):
|
|
'''
|
|
Test cases for salt.states.composer
|
|
'''
|
|
# 'installed' function tests: 1
|
|
|
|
def test_installed(self):
|
|
'''
|
|
Test to verify that the correct versions of composer
|
|
dependencies are present.
|
|
'''
|
|
name = 'CURL'
|
|
|
|
ret = {'name': name, 'result': True, 'comment': '', 'changes': {}}
|
|
|
|
mock = MagicMock(return_value=True)
|
|
with patch.dict(composer.__salt__,
|
|
{'composer.did_composer_install': mock}):
|
|
comt = ('Composer already installed this directory')
|
|
ret.update({'comment': comt})
|
|
self.assertDictEqual(composer.installed(name, always_check=False),
|
|
ret)
|
|
|
|
with patch.dict(composer.__opts__, {'test': True}):
|
|
comt = ('The state of "CURL" will be changed.')
|
|
changes = {'new': 'composer install will be run in CURL',
|
|
'old': 'composer install has been run in CURL'}
|
|
ret.update({'comment': comt, 'result': None,
|
|
'changes': changes})
|
|
self.assertDictEqual(composer.installed(name), ret)
|
|
|
|
with patch.dict(composer.__opts__, {'test': False}):
|
|
mock = MagicMock(side_effect=[SaltException, {}])
|
|
with patch.dict(composer.__salt__, {'composer.install': mock}):
|
|
comt = ("Error executing composer in "
|
|
"'CURL': ")
|
|
ret.update({'comment': comt, 'result': False,
|
|
'changes': {}})
|
|
self.assertDictEqual(composer.installed(name), ret)
|
|
|
|
comt = ('Composer install completed successfully,'
|
|
' output silenced by quiet flag')
|
|
ret.update({'comment': comt, 'result': True})
|
|
self.assertDictEqual(composer.installed(name, quiet=True),
|
|
ret)
|
|
|
|
# 'update' function tests: 1
|
|
|
|
def test_update(self):
|
|
'''
|
|
Test to composer update the directory to ensure we have
|
|
the latest versions of all project dependencies.
|
|
'''
|
|
name = 'CURL'
|
|
|
|
ret = {'name': name, 'result': True, 'comment': '', 'changes': {}}
|
|
|
|
changes = {'new': 'composer install/update will be run in CURL',
|
|
'old': 'composer install has not yet been run in CURL'}
|
|
|
|
mock = MagicMock(return_value=True)
|
|
with patch.dict(composer.__salt__,
|
|
{'composer.did_composer_install': mock}):
|
|
with patch.dict(composer.__opts__, {'test': True}):
|
|
comt = ('The state of "CURL" will be changed.')
|
|
ret.update({'comment': comt, 'result': None,
|
|
'changes': changes})
|
|
self.assertDictEqual(composer.update(name), ret)
|
|
|
|
with patch.dict(composer.__opts__, {'test': False}):
|
|
mock = MagicMock(side_effect=[SaltException, {}])
|
|
with patch.dict(composer.__salt__, {'composer.update': mock}):
|
|
comt = ("Error executing composer in "
|
|
"'CURL': ")
|
|
ret.update({'comment': comt, 'result': False,
|
|
'changes': {}})
|
|
self.assertDictEqual(composer.update(name), ret)
|
|
|
|
comt = ('Composer update completed successfully,'
|
|
' output silenced by quiet flag')
|
|
ret.update({'comment': comt, 'result': True})
|
|
self.assertDictEqual(composer.update(name, quiet=True),
|
|
ret)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
from integration import run_tests
|
|
run_tests(ComposerTestCase, needs_daemon=False)
|