mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
fixing test_mac_desktop.py test_mac_keychain.py test_mac_power.py test_mac_power_wake_on_modem.py test_mac_service.py
This commit is contained in:
parent
f76bcef411
commit
3aab2f7c26
4 changed files with 76 additions and 48 deletions
|
@ -4,6 +4,8 @@ Integration tests for the mac_desktop execution module.
|
|||
|
||||
import pytest
|
||||
|
||||
from salt.exceptions import CommandExecutionError
|
||||
|
||||
pytestmark = [
|
||||
pytest.mark.slow_test,
|
||||
pytest.mark.destructive_test,
|
||||
|
@ -49,8 +51,9 @@ def test_screensaver(desktop):
|
|||
"""
|
||||
Tests the return of the screensaver function.
|
||||
"""
|
||||
ret = desktop.screensaver()
|
||||
if "does not exist" in ret:
|
||||
try:
|
||||
ret = desktop.screensaver()
|
||||
except CommandExecutionError as exc:
|
||||
pytest.skip("Skipping. Screensaver unavailable.")
|
||||
assert ret
|
||||
|
||||
|
@ -59,8 +62,9 @@ def test_lock(desktop):
|
|||
"""
|
||||
Tests the return of the lock function.
|
||||
"""
|
||||
ret = desktop.lock()
|
||||
if "Unable to run" in ret:
|
||||
try:
|
||||
ret = desktop.lock()
|
||||
except CommandExecutionError as exc:
|
||||
pytest.skip("Skipping. Unable to lock screen.")
|
||||
assert ret
|
||||
|
||||
|
|
|
@ -84,7 +84,7 @@ def test_mac_keychain_uninstall(keychain, setup_teardown_vars):
|
|||
|
||||
|
||||
@pytest.mark.skip_if_binaries_missing("openssl")
|
||||
def test_mac_keychain_get_friendly_name(keychain, shell):
|
||||
def test_mac_keychain_get_friendly_name(keychain, shell, setup_teardown_vars):
|
||||
"""
|
||||
Test that attempts to get friendly name of a cert
|
||||
"""
|
||||
|
|
|
@ -4,6 +4,8 @@ integration tests for mac_power
|
|||
|
||||
import pytest
|
||||
|
||||
from salt.exceptions import SaltInvocationError
|
||||
|
||||
pytestmark = [
|
||||
pytest.mark.flaky(max_runs=10),
|
||||
pytest.mark.skip_if_binaries_missing("systemsetup"),
|
||||
|
@ -52,17 +54,21 @@ def test_computer_sleep(power):
|
|||
assert ret == "Never"
|
||||
|
||||
# Test invalid input
|
||||
ret = power.set_computer_sleep("spongebob")
|
||||
assert "Invalid String Value for Minutes" in ret
|
||||
with pytest.raises(SaltInvocationError) as exc:
|
||||
power.set_computer_sleep("spongebob")
|
||||
assert "Invalid String Value for Minutes" in str(exc.value)
|
||||
|
||||
ret = power.set_computer_sleep(0)
|
||||
assert "Invalid Integer Value for Minutes" in ret
|
||||
with pytest.raises(SaltInvocationError) as exc:
|
||||
power.set_computer_sleep(0)
|
||||
assert "Invalid Integer Value for Minutes" in str(exc.value)
|
||||
|
||||
ret = power.set_computer_sleep(181)
|
||||
assert "Invalid Integer Value for Minutes" in ret
|
||||
with pytest.raises(SaltInvocationError) as exc:
|
||||
power.set_computer_sleep(181)
|
||||
assert "Invalid Integer Value for Minutes" in str(exc.value)
|
||||
|
||||
ret = power.set_computer_sleep(True)
|
||||
assert "Invalid Boolean Value for Minutes" in ret
|
||||
with pytest.raises(SaltInvocationError) as exc:
|
||||
power.set_computer_sleep(True)
|
||||
assert "Invalid Boolean Value for Minutes" in str(exc.value)
|
||||
|
||||
|
||||
def test_display_sleep(power):
|
||||
|
@ -85,17 +91,21 @@ def test_display_sleep(power):
|
|||
assert ret == "Never"
|
||||
|
||||
# Test invalid input
|
||||
ret = power.set_display_sleep("spongebob")
|
||||
assert "Invalid String Value for Minutes" in ret
|
||||
with pytest.raises(SaltInvocationError) as exc:
|
||||
power.set_display_sleep("spongebob")
|
||||
assert "Invalid String Value for Minutes" in str(exc.value)
|
||||
|
||||
ret = power.set_display_sleep(0)
|
||||
assert "Invalid Integer Value for Minutes" in ret
|
||||
with pytest.raises(SaltInvocationError) as exc:
|
||||
power.set_display_sleep(0)
|
||||
assert "Invalid Integer Value for Minutes" in str(exc.value)
|
||||
|
||||
ret = power.set_display_sleep(181)
|
||||
assert "Invalid Integer Value for Minutes" in ret
|
||||
with pytest.raises(SaltInvocationError) as exc:
|
||||
power.set_display_sleep(181)
|
||||
assert "Invalid Integer Value for Minutes" in str(exc.value)
|
||||
|
||||
ret = power.set_display_sleep(True)
|
||||
assert "Invalid Boolean Value for Minutes" in ret
|
||||
with pytest.raises(SaltInvocationError) as exc:
|
||||
power.set_display_sleep(True)
|
||||
assert "Invalid Boolean Value for Minutes" in str(exc.value)
|
||||
|
||||
|
||||
def test_harddisk_sleep(power):
|
||||
|
@ -118,17 +128,21 @@ def test_harddisk_sleep(power):
|
|||
assert ret == "Never"
|
||||
|
||||
# Test invalid input
|
||||
ret = power.set_harddisk_sleep("spongebob")
|
||||
assert "Invalid String Value for Minutes" in ret
|
||||
with pytest.raises(SaltInvocationError) as exc:
|
||||
power.set_harddisk_sleep("spongebob")
|
||||
assert "Invalid String Value for Minutes" in str(exc.value)
|
||||
|
||||
ret = power.set_harddisk_sleep(0)
|
||||
assert "Invalid Integer Value for Minutes" in ret
|
||||
with pytest.raises(SaltInvocationError) as exc:
|
||||
power.set_harddisk_sleep(0)
|
||||
assert "Invalid Integer Value for Minutes" in str(exc.value)
|
||||
|
||||
ret = power.set_harddisk_sleep(181)
|
||||
assert "Invalid Integer Value for Minutes" in ret
|
||||
with pytest.raises(SaltInvocationError) as exc:
|
||||
power.set_harddisk_sleep(181)
|
||||
assert "Invalid Integer Value for Minutes" in str(exc.value)
|
||||
|
||||
ret = power.set_harddisk_sleep(True)
|
||||
assert "Invalid Boolean Value for Minutes" in ret
|
||||
with pytest.raises(SaltInvocationError) as exc:
|
||||
power.set_harddisk_sleep(True)
|
||||
assert "Invalid Boolean Value for Minutes" in str(exc.value)
|
||||
|
||||
|
||||
def test_restart_freeze(power):
|
||||
|
|
|
@ -7,6 +7,7 @@ import plistlib
|
|||
import pytest
|
||||
|
||||
import salt.utils.files
|
||||
from salt.exceptions import CommandExecutionError
|
||||
|
||||
pytestmark = [
|
||||
pytest.mark.slow_test,
|
||||
|
@ -21,7 +22,7 @@ def service(modules):
|
|||
|
||||
|
||||
@pytest.fixture(scope="function", autouse=True)
|
||||
def service_name(sergice, service_name):
|
||||
def service_name(service, service_name):
|
||||
|
||||
service_name = "com.salt.integration.test"
|
||||
service_path = "/Library/LaunchDaemons/com.salt.integration.test.plist"
|
||||
|
@ -54,8 +55,9 @@ def test_show(service, service_name):
|
|||
assert service_info.data["plist"]["Label"] == service_name
|
||||
|
||||
# Missing Service
|
||||
ret = service.show("spongebob")
|
||||
assert "Service not found" in ret
|
||||
with pytest.raises(CommandExecutionError) as exc:
|
||||
ret = service.show("spongebob")
|
||||
assert "Service not found" in str(exc.value)
|
||||
|
||||
|
||||
def test_launchctl(service, service_name):
|
||||
|
@ -70,8 +72,9 @@ def test_launchctl(service, service_name):
|
|||
assert ret == "64: unknown error code"
|
||||
|
||||
# Raise an error
|
||||
ret = service.launchctl("error", "bootstrap")
|
||||
assert "Failed to error service" in ret
|
||||
with pytest.raises(CommandExecutionError) as exc:
|
||||
ret = service.launchctl("error", "bootstrap")
|
||||
assert "Failed to error service" in str(exc.value)
|
||||
|
||||
|
||||
def test_list(service, service_name):
|
||||
|
@ -85,8 +88,9 @@ def test_list(service, service_name):
|
|||
assert "{" in ret
|
||||
|
||||
# Service not found
|
||||
ret = service.list("spongebob")
|
||||
assert "Service not found" in ret
|
||||
with pytest.raises(CommandExecutionError) as exc:
|
||||
ret = service.list("spongebob")
|
||||
assert "Service not found" in str(exc.value)
|
||||
|
||||
|
||||
def test_enable(service, service_name):
|
||||
|
@ -96,8 +100,9 @@ def test_enable(service, service_name):
|
|||
ret = service.enable(service_name)
|
||||
assert ret
|
||||
|
||||
ret = service.enable("spongebob")
|
||||
assert "Service not found" in ret
|
||||
with pytest.raises(CommandExecutionError) as exc:
|
||||
ret = service.enable("spongebob")
|
||||
assert "Service not found" in str(exc.value)
|
||||
|
||||
|
||||
def test_disable(service, service_name):
|
||||
|
@ -107,8 +112,9 @@ def test_disable(service, service_name):
|
|||
ret = service.disable(service_name)
|
||||
assert ret
|
||||
|
||||
ret = service.disable("spongebob")
|
||||
assert "Service not found" in ret
|
||||
with pytest.raises(CommandExecutionError) as exc:
|
||||
ret = service.disable("spongebob")
|
||||
assert "Service not found" in str(exc.value)
|
||||
|
||||
|
||||
def test_start(service, service_name):
|
||||
|
@ -121,8 +127,9 @@ def test_start(service, service_name):
|
|||
ret = service.start(service_name)
|
||||
assert ret
|
||||
|
||||
ret = service.start("spongebob")
|
||||
assert "Service not found" in ret
|
||||
with pytest.raises(CommandExecutionError) as exc:
|
||||
ret = service.start("spongebob")
|
||||
assert "Service not found" in str(exc.value)
|
||||
|
||||
|
||||
def test_stop(service, service_name):
|
||||
|
@ -132,8 +139,9 @@ def test_stop(service, service_name):
|
|||
ret = service.stop(service_name)
|
||||
assert ret
|
||||
|
||||
ret = service.stop("spongebob")
|
||||
assert "Service not found" in ret
|
||||
with pytest.raises(CommandExecutionError) as exc:
|
||||
ret = service.stop("spongebob")
|
||||
assert "Service not found" in str(exc.value)
|
||||
|
||||
|
||||
def test_status(service, service_name):
|
||||
|
@ -185,8 +193,9 @@ def test_enabled(service, service_name):
|
|||
ret = service.enabled(service_name)
|
||||
assert ret
|
||||
|
||||
ret = service.enabled("spongebob")
|
||||
assert "Service not found: spongebob" in ret
|
||||
with pytest.raises(CommandExecutionError) as exc:
|
||||
ret = service.enabled("spongebob")
|
||||
assert "Service not found: spongebob" in str(exc.value)
|
||||
|
||||
|
||||
def test_disabled(service, service_name):
|
||||
|
@ -208,8 +217,9 @@ def test_disabled(service, service_name):
|
|||
ret = service.enable(service_name)
|
||||
assert ret
|
||||
|
||||
ret = service.disable("spongebob")
|
||||
assert "Service not found: spongebob" in ret
|
||||
with pytest.raises(CommandExecutionError) as exc:
|
||||
ret = service.disable("spongebob")
|
||||
assert "Service not found: spongebob" in str(exc.value)
|
||||
|
||||
|
||||
def test_get_all(service, service_name):
|
||||
|
|
Loading…
Add table
Reference in a new issue