mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Fix timezone with dst off
This commit is contained in:
parent
a0c23d7be7
commit
fe80693e40
3 changed files with 19 additions and 1 deletions
2
changelog/58379.fixed
Normal file
2
changelog/58379.fixed
Normal file
|
@ -0,0 +1,2 @@
|
|||
Fixed issue with win_timezone when dst is turned off. This was causing the
|
||||
minion not to start
|
|
@ -224,7 +224,8 @@ def get_zone():
|
|||
raise CommandExecutionError(
|
||||
"tzutil encountered an error getting timezone", info=res
|
||||
)
|
||||
return mapper.get_unix(res["stdout"].lower(), "Unknown")
|
||||
tz = res["stdout"].lower().strip("_dstoff")
|
||||
return mapper.get_unix(tz, "Unknown")
|
||||
|
||||
|
||||
def get_offset():
|
||||
|
|
|
@ -39,6 +39,21 @@ class WinTimezoneTestCase(TestCase, LoaderModuleMockMixin):
|
|||
with patch.dict(win_timezone.__salt__, {"cmd.run_all": mock_read_ok}):
|
||||
self.assertEqual(win_timezone.get_zone(), "Asia/Calcutta")
|
||||
|
||||
def test_get_zone_normal_dstoff(self):
|
||||
"""
|
||||
Test if it gets current timezone with dst off (i.e. America/Denver)
|
||||
"""
|
||||
mock_read_ok = MagicMock(
|
||||
return_value={
|
||||
"pid": 78,
|
||||
"retcode": 0,
|
||||
"stderr": "",
|
||||
"stdout": "Mountain Standard Time_dstoff",
|
||||
}
|
||||
)
|
||||
with patch.dict(win_timezone.__salt__, {"cmd.run_all": mock_read_ok}):
|
||||
self.assertEqual(win_timezone.get_zone(), "America/Denver")
|
||||
|
||||
def test_get_zone_unknown(self):
|
||||
"""
|
||||
Test get_zone with unknown timezone (i.e. Indian Standard Time)
|
||||
|
|
Loading…
Add table
Reference in a new issue