mirror of
https://github.com/valitydev/salt.git
synced 2024-11-07 17:09:03 +00:00
Refactor update
This commit is contained in:
parent
d41e62b1d3
commit
182b80d67e
@ -324,14 +324,9 @@ def update(name):
|
|||||||
|
|
||||||
.. code-block:: bash
|
.. code-block:: bash
|
||||||
|
|
||||||
salt '*' softwareupdate.install <update-name>
|
salt '*' softwareupdate.update <update-name>
|
||||||
'''
|
'''
|
||||||
try:
|
if not update_available(name):
|
||||||
updates = _get_available()
|
|
||||||
except CommandExecutionError as exc:
|
|
||||||
raise CommandExecutionError(exc)
|
|
||||||
|
|
||||||
if name not in updates:
|
|
||||||
raise SaltInvocationError('Update not available: {0}'.format(name))
|
raise SaltInvocationError('Update not available: {0}'.format(name))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@ -340,12 +335,7 @@ def update(name):
|
|||||||
except CommandExecutionError as exc:
|
except CommandExecutionError as exc:
|
||||||
raise CommandExecutionError(exc)
|
raise CommandExecutionError(exc)
|
||||||
|
|
||||||
try:
|
return not update_available(name)
|
||||||
updates = _get_available()
|
|
||||||
except CommandExecutionError as exc:
|
|
||||||
raise CommandExecutionError(exc)
|
|
||||||
|
|
||||||
return name not in updates
|
|
||||||
|
|
||||||
|
|
||||||
def update_available(name):
|
def update_available(name):
|
||||||
|
@ -113,15 +113,22 @@ class MacSoftwareUpdateModuleTest(integration.ModuleCase):
|
|||||||
self.assertFalse(self.run_function('softwareupdate.schedule_enabled'))
|
self.assertFalse(self.run_function('softwareupdate.schedule_enabled'))
|
||||||
|
|
||||||
@destructiveTest
|
@destructiveTest
|
||||||
def test_update_all(self):
|
def test_update(self):
|
||||||
'''
|
'''
|
||||||
Test softwareupdate.update_all
|
Test softwareupdate.update_all
|
||||||
|
Test softwareupdate.update
|
||||||
|
Test softwareupdate.update_available
|
||||||
'''
|
'''
|
||||||
# There's no way to know what the dictionary will contain, so all we can
|
# There's no way to know what the dictionary will contain, so all we can
|
||||||
# check is that the return is a dictionary
|
# check is that the return is a dictionary
|
||||||
self.assertIsInstance(
|
self.assertIsInstance(
|
||||||
self.run_function('softwareupdate.update_all'), dict)
|
self.run_function('softwareupdate.update_all'), dict)
|
||||||
|
|
||||||
|
# Test update not available
|
||||||
|
self.assertIn(
|
||||||
|
'Update not available',
|
||||||
|
self.run_function('softwareupdate.update', ['spongebob']))
|
||||||
|
|
||||||
@destructiveTest
|
@destructiveTest
|
||||||
def test_install(self):
|
def test_install(self):
|
||||||
'''
|
'''
|
||||||
|
Loading…
Reference in New Issue
Block a user