Skip to content

Commit d18969d

Browse files
garethgreenawaydwoz
authored andcommitted
unskips and fixes to test_mac_timezone.py
1 parent 206be54 commit d18969d

File tree

1 file changed

+28
-15
lines changed

1 file changed

+28
-15
lines changed

tests/pytests/functional/modules/test_mac_timezone.py

Lines changed: 28 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313

1414
import pytest
1515

16+
from salt.exceptions import SaltInvocationError
17+
1618
pytestmark = [
1719
pytest.mark.skip_if_binaries_missing("systemsetup"),
1820
pytest.mark.slow_test,
@@ -62,11 +64,12 @@ def test_get_set_date(timezone):
6264
assert ret == "2/20/2011"
6365

6466
# Test bad date format
65-
ret = timezone.set_date("13/12/2014")
66-
assert (
67-
ret
68-
== "ERROR executing 'timezone.set_date': Invalid Date/Time Format: 13/12/2014"
69-
)
67+
with pytest.raises(SaltInvocationError) as exc:
68+
ret = timezone.set_date("13/12/2014")
69+
assert (
70+
"ERROR executing 'timezone.set_date': Invalid Date/Time Format: 13/12/2014"
71+
in str(exc.value)
72+
)
7073

7174

7275
@pytest.mark.slow_test
@@ -80,9 +83,6 @@ def test_get_time(timezone):
8083
assert isinstance(obj_date, datetime.date)
8184

8285

83-
@pytest.mark.skip(
84-
reason="Skip until we can figure out why modifying the system clock causes ZMQ errors",
85-
)
8686
@pytest.mark.destructive_test
8787
def test_set_time(timezone):
8888
"""
@@ -93,8 +93,12 @@ def test_set_time(timezone):
9393
assert ret
9494

9595
# Test bad time format
96-
ret = timezone.set_time("3:71")
97-
assert ret == "ERROR executing 'timezone.set_time': Invalid Date/Time Format: 3:71"
96+
with pytest.raises(SaltInvocationError) as exc:
97+
ret = timezone.set_time("3:71")
98+
assert (
99+
"ERROR executing 'timezone.set_time': Invalid Date/Time Format: 3:71"
100+
in str(exc.value)
101+
)
98102

99103

100104
@pytest.mark.destructive_test
@@ -106,11 +110,17 @@ def test_get_set_zone(timezone):
106110
# Correct Functionality
107111
ret = timezone.set_zone("Pacific/Wake")
108112
assert ret
113+
114+
ret = timezone.get_zone()
109115
assert ret == "Pacific/Wake"
110116

111117
# Test bad time zone
112-
ret = timezone.set_zone("spongebob")
113-
assert ret == "ERROR executing 'timezone.set_zone': Invalid Timezone: spongebob"
118+
with pytest.raises(SaltInvocationError) as exc:
119+
ret = timezone.set_zone("spongebob")
120+
assert (
121+
"ERROR executing 'timezone.set_zone': Invalid Timezone: spongebob"
122+
in str(exc.value)
123+
)
114124

115125

116126
@pytest.mark.destructive_test
@@ -126,8 +136,9 @@ def test_get_offset(timezone):
126136

127137
ret = timezone.set_zone("America/Los_Angeles")
128138
assert ret
139+
ret = timezone.get_offset()
129140
assert isinstance(ret, str)
130-
assert ret == "-0700"
141+
assert ret == "-0800"
131142

132143

133144
@pytest.mark.destructive_test
@@ -138,13 +149,15 @@ def test_get_set_zonecode(timezone):
138149
"""
139150
ret = timezone.set_zone("America/Los_Angeles")
140151
assert ret
152+
ret = timezone.get_zone()
141153
assert isinstance(ret, str)
142-
assert ret == "PDT"
154+
assert ret == "America/Los_Angeles"
143155

144156
ret = timezone.set_zone("Pacific/Wake")
145157
assert ret
158+
ret = timezone.get_zone()
146159
assert isinstance(ret, str)
147-
assert ret == "WAKT"
160+
assert ret == "Pacific/Wake"
148161

149162

150163
@pytest.mark.slow_test

0 commit comments

Comments
 (0)