mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Add assert_called_with
This commit is contained in:
parent
1bf70b2033
commit
6080633613
1 changed files with 59 additions and 1 deletions
|
@ -9,7 +9,7 @@ import os
|
|||
|
||||
# Import Salt Testing Libs
|
||||
from tests.support.unit import TestCase, skipIf
|
||||
from tests.support.mock import MagicMock, patch, NO_MOCK, NO_MOCK_REASON
|
||||
from tests.support.mock import MagicMock, patch, NO_MOCK, NO_MOCK_REASON, call
|
||||
|
||||
# Import Salt libs
|
||||
import salt.utils.mac_utils as mac_utils
|
||||
|
@ -349,6 +349,35 @@ class MacUtilsTestCase(TestCase):
|
|||
|
||||
ret = mac_utils.available_services()
|
||||
|
||||
cmd = '/usr/bin/plutil -convert xml1 -o - -- "{0}"'
|
||||
calls = [
|
||||
call(cmd.format(os.path.realpath(os.path.join(
|
||||
'/Library/LaunchAgents', 'com.apple.lla1.plist'))),
|
||||
output_loglevel='quiet'),
|
||||
call(cmd.format(os.path.realpath(os.path.join(
|
||||
'/Library/LaunchAgents', 'com.apple.lla2.plist'))),
|
||||
output_loglevel='quiet'),
|
||||
call(cmd.format(os.path.realpath(os.path.join(
|
||||
'/Library/LaunchDaemons', 'com.apple.lld1.plist'))),
|
||||
output_loglevel='quiet'),
|
||||
call(cmd.format(os.path.realpath(os.path.join(
|
||||
'/Library/LaunchDaemons', 'com.apple.lld2.plist'))),
|
||||
output_loglevel='quiet'),
|
||||
call(cmd.format(os.path.realpath(os.path.join(
|
||||
'/System/Library/LaunchAgents', 'com.apple.slla1.plist'))),
|
||||
output_loglevel='quiet'),
|
||||
call(cmd.format(os.path.realpath(os.path.join(
|
||||
'/System/Library/LaunchAgents', 'com.apple.slla2.plist'))),
|
||||
output_loglevel='quiet'),
|
||||
call(cmd.format(os.path.realpath(os.path.join(
|
||||
'/System/Library/LaunchDaemons', 'com.apple.slld1.plist'))),
|
||||
output_loglevel='quiet'),
|
||||
call(cmd.format(os.path.realpath(os.path.join(
|
||||
'/System/Library/LaunchDaemons', 'com.apple.slld2.plist'))),
|
||||
output_loglevel='quiet'),
|
||||
]
|
||||
mock_run.assert_has_calls(calls)
|
||||
|
||||
# Make sure it's a dict with 8 items
|
||||
self.assertTrue(isinstance(ret, dict))
|
||||
self.assertEqual(len(ret), 8)
|
||||
|
@ -398,6 +427,35 @@ class MacUtilsTestCase(TestCase):
|
|||
|
||||
ret = mac_utils.available_services()
|
||||
|
||||
cmd = '/usr/bin/plutil -convert xml1 -o - -- "{0}"'
|
||||
calls = [
|
||||
call(cmd.format(os.path.realpath(os.path.join(
|
||||
'/Library/LaunchAgents', 'com.apple.lla1.plist'))),
|
||||
output_loglevel='quiet'),
|
||||
call(cmd.format(os.path.realpath(os.path.join(
|
||||
'/Library/LaunchAgents', 'com.apple.lla2.plist'))),
|
||||
output_loglevel='quiet'),
|
||||
call(cmd.format(os.path.realpath(os.path.join(
|
||||
'/Library/LaunchDaemons', 'com.apple.lld1.plist'))),
|
||||
output_loglevel='quiet'),
|
||||
call(cmd.format(os.path.realpath(os.path.join(
|
||||
'/Library/LaunchDaemons', 'com.apple.lld2.plist'))),
|
||||
output_loglevel='quiet'),
|
||||
call(cmd.format(os.path.realpath(os.path.join(
|
||||
'/System/Library/LaunchAgents', 'com.apple.slla1.plist'))),
|
||||
output_loglevel='quiet'),
|
||||
call(cmd.format(os.path.realpath(os.path.join(
|
||||
'/System/Library/LaunchAgents', 'com.apple.slla2.plist'))),
|
||||
output_loglevel='quiet'),
|
||||
call(cmd.format(os.path.realpath(os.path.join(
|
||||
'/System/Library/LaunchDaemons', 'com.apple.slld1.plist'))),
|
||||
output_loglevel='quiet'),
|
||||
call(cmd.format(os.path.realpath(os.path.join(
|
||||
'/System/Library/LaunchDaemons', 'com.apple.slld2.plist'))),
|
||||
output_loglevel='quiet'),
|
||||
]
|
||||
mock_run.assert_has_calls(calls)
|
||||
|
||||
# Make sure it's a dict with 8 items
|
||||
self.assertTrue(isinstance(ret, dict))
|
||||
self.assertEqual(len(ret), 8)
|
||||
|
|
Loading…
Add table
Reference in a new issue