Fix timezone with dst off

This commit is contained in:
twangboy 2021-01-21 16:13:40 -07:00 committed by Megan Wilhite
parent a0c23d7be7
commit fe80693e40
3 changed files with 19 additions and 1 deletions

2
changelog/58379.fixed Normal file
View file

@ -0,0 +1,2 @@
Fixed issue with win_timezone when dst is turned off. This was causing the
minion not to start

View file

@ -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():

View file

@ -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)