mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
update timezone mod unit tests for errors
This commit is contained in:
parent
ef26f067b2
commit
bc0f167850
1 changed files with 14 additions and 4 deletions
|
@ -40,11 +40,21 @@ class TimezoneTestCase(TestCase):
|
|||
'''
|
||||
Test to get current timezone (i.e. America/Denver)
|
||||
'''
|
||||
mock = MagicMock(side_effect=['Time zone: A', 'A'])
|
||||
with patch.object(salt.utils, 'which', return_value=True):
|
||||
with patch.dict(timezone.__salt__, {'cmd.run': mock}):
|
||||
self.assertEqual(timezone.get_zone(), 'A')
|
||||
zone = 'MST'
|
||||
|
||||
with patch.object(salt.utils, 'which', return_value=True):
|
||||
mock_cmd = MagicMock(return_value={'stderr': 'error', 'retcode': 1})
|
||||
with patch.dict(timezone.__salt__, {'cmd.run_all': mock_cmd}):
|
||||
self.assertRaises(CommandExecutionError, timezone.get_zone)
|
||||
|
||||
mock_cmd = MagicMock(return_value={'stdout': 'Timezone: {0}'.format(zone),
|
||||
'retcode': 0})
|
||||
with patch.dict(timezone.__salt__, {'cmd.run_all': mock_cmd}):
|
||||
self.assertEqual(timezone.get_zone(), zone)
|
||||
|
||||
mock_cmd = MagicMock(return_value={'stdout': 'ZoneCTL: {0}'.format(zone),
|
||||
'retcode': 0})
|
||||
with patch.dict(timezone.__salt__, {'cmd.run_all': mock_cmd}):
|
||||
self.assertRaises(CommandExecutionError, timezone.get_zone)
|
||||
|
||||
with patch.object(salt.utils, 'which', return_value=False):
|
||||
|
|
Loading…
Add table
Reference in a new issue