mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Replace @skipIf(not platform.is_windows(), ...)
usage
Signed-off-by: Pedro Algarvio <palgarvio@vmware.com>
This commit is contained in:
parent
d27aa89085
commit
b839a6c3a8
26 changed files with 70 additions and 75 deletions
|
@ -60,7 +60,7 @@ class TestGrainsReg(ModuleCase, LoaderModuleMockMixin):
|
|||
utils = salt.loader.utils(opts, whitelist=["reg"])
|
||||
return {salt.modules.reg: {"__opts__": opts, "__utils__": utils}}
|
||||
|
||||
@skipIf(not salt.utils.platform.is_windows(), "Only run on Windows")
|
||||
@pytest.mark.skip_unless_on_windows
|
||||
@pytest.mark.slow_test
|
||||
def test_win_cpu_model(self):
|
||||
"""
|
||||
|
|
|
@ -4,10 +4,9 @@ import salt.utils.path
|
|||
import salt.utils.platform
|
||||
from tests.support.case import ModuleCase
|
||||
from tests.support.sminion import create_sminion
|
||||
from tests.support.unit import skipIf
|
||||
|
||||
|
||||
@skipIf(not salt.utils.platform.is_windows(), "Tests for only Windows")
|
||||
@pytest.mark.skip_unless_on_windows
|
||||
@pytest.mark.windows_whitelisted
|
||||
@pytest.mark.destructive_test
|
||||
class ChocolateyModuleTest(ModuleCase):
|
||||
|
|
|
@ -3,13 +3,9 @@ Integration tests for timezone module
|
|||
|
||||
Linux and Solaris are supported
|
||||
"""
|
||||
|
||||
|
||||
import pytest
|
||||
|
||||
import salt.utils.platform
|
||||
from tests.support.case import ModuleCase
|
||||
from tests.support.unit import skipIf
|
||||
|
||||
try:
|
||||
import tzlocal # pylint: disable=unused-import
|
||||
|
@ -51,7 +47,7 @@ class TimezoneSolarisModuleTest(ModuleCase):
|
|||
self.assertIn(ret, timescale)
|
||||
|
||||
|
||||
@skipIf(not salt.utils.platform.is_windows(), "windows test only")
|
||||
@pytest.mark.skip_unless_on_windows
|
||||
class TimezoneWindowsModuleTest(ModuleCase):
|
||||
def setUp(self):
|
||||
self.pre = self.run_function("timezone.get_zone")
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
import pytest
|
||||
|
||||
import salt.utils.platform
|
||||
from tests.support.case import ModuleCase
|
||||
from tests.support.unit import skipIf
|
||||
|
||||
|
||||
@skipIf(not salt.utils.platform.is_windows(), "windows tests only")
|
||||
@pytest.mark.skip_unless_on_windows
|
||||
@pytest.mark.windows_whitelisted
|
||||
class AutoRunsModuleTest(ModuleCase):
|
||||
"""
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
import pytest
|
||||
|
||||
import salt.utils.platform
|
||||
from tests.support.case import ModuleCase
|
||||
from tests.support.unit import skipIf
|
||||
|
||||
|
||||
@skipIf(not salt.utils.platform.is_windows(), "windows test only")
|
||||
@pytest.mark.skip_unless_on_windows
|
||||
@pytest.mark.windows_whitelisted
|
||||
class WinDNSTest(ModuleCase):
|
||||
"""
|
||||
|
@ -20,7 +18,8 @@ class WinDNSTest(ModuleCase):
|
|||
"""
|
||||
# Get a list of interfaces on the system
|
||||
interfaces = self.run_function("network.interfaces_names")
|
||||
skipIf(interfaces.count == 0, "This test requires a network interface")
|
||||
if not interfaces.count:
|
||||
pytest.skip("This test requires a network interface")
|
||||
|
||||
interface = interfaces[0]
|
||||
dns = "8.8.8.8"
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
import pytest
|
||||
|
||||
import salt.utils.platform
|
||||
from tests.support.case import ModuleCase
|
||||
from tests.support.unit import skipIf
|
||||
|
||||
|
||||
@skipIf(not salt.utils.platform.is_windows(), "Tests for only Windows")
|
||||
@pytest.mark.skip_unless_on_windows
|
||||
@pytest.mark.windows_whitelisted
|
||||
class FirewallTest(ModuleCase):
|
||||
"""
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
import re
|
||||
|
||||
import salt.utils.platform
|
||||
import pytest
|
||||
|
||||
from tests.support.case import ModuleCase
|
||||
from tests.support.unit import skipIf
|
||||
|
||||
|
||||
@skipIf(not salt.utils.platform.is_windows(), "windows test only")
|
||||
@pytest.mark.skip_unless_on_windows
|
||||
class WinIPTest(ModuleCase):
|
||||
"""
|
||||
Tests for salt.modules.win_ip
|
||||
|
|
|
@ -7,10 +7,9 @@ import salt.utils.files
|
|||
import salt.utils.platform
|
||||
from tests.support.case import ModuleCase
|
||||
from tests.support.runtests import RUNTIME_VARS
|
||||
from tests.support.unit import skipIf
|
||||
|
||||
|
||||
@skipIf(not salt.utils.platform.is_windows(), "windows test only")
|
||||
@pytest.mark.skip_unless_on_windows
|
||||
@pytest.mark.windows_whitelisted
|
||||
class WinPKGTest(ModuleCase):
|
||||
"""
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
import pytest
|
||||
|
||||
import salt.utils.platform
|
||||
from tests.support.case import ModuleCase
|
||||
from tests.support.unit import skipIf
|
||||
|
||||
|
||||
@skipIf(not salt.utils.platform.is_windows(), "windows test only")
|
||||
@pytest.mark.skip_unless_on_windows
|
||||
@pytest.mark.windows_whitelisted
|
||||
class WinServermanagerTest(ModuleCase):
|
||||
"""
|
||||
|
|
|
@ -1,13 +1,11 @@
|
|||
import pytest
|
||||
|
||||
import salt.modules.win_task as task
|
||||
import salt.utils.platform
|
||||
from salt.exceptions import CommandExecutionError
|
||||
from tests.support.case import ModuleCase
|
||||
from tests.support.unit import skipIf
|
||||
|
||||
|
||||
@skipIf(not salt.utils.platform.is_windows(), "windows test only")
|
||||
@pytest.mark.skip_unless_on_windows
|
||||
class WinTasksTest(ModuleCase):
|
||||
"""
|
||||
Tests for salt.modules.win_task.
|
||||
|
|
|
@ -6,17 +6,15 @@ import logging
|
|||
|
||||
import pytest
|
||||
|
||||
import salt.utils.platform
|
||||
from tests.support.case import ModuleCase
|
||||
from tests.support.mixins import SaltReturnAssertsMixin
|
||||
from tests.support.unit import skipIf
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
__testcontext__ = {}
|
||||
|
||||
|
||||
@skipIf(not salt.utils.platform.is_windows(), "Windows Specific Test")
|
||||
@pytest.mark.skip_unless_on_windows
|
||||
@pytest.mark.destructive_test
|
||||
class ChocolateyTest(ModuleCase, SaltReturnAssertsMixin):
|
||||
"""
|
||||
|
|
|
@ -7,11 +7,9 @@ import logging
|
|||
import pytest
|
||||
from saltfactories.utils import random_string
|
||||
|
||||
import salt.utils.platform
|
||||
import salt.utils.win_reg as reg
|
||||
from tests.support.case import ModuleCase
|
||||
from tests.support.mixins import SaltReturnAssertsMixin
|
||||
from tests.support.unit import skipIf
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
@ -23,7 +21,7 @@ FAKE_KEY = "SOFTWARE\\{}".format(random_string("SaltTesting-", lowercase=False))
|
|||
|
||||
|
||||
@pytest.mark.destructive_test
|
||||
@skipIf(not salt.utils.platform.is_windows(), "Windows Specific Test")
|
||||
@pytest.mark.skip_unless_on_windows
|
||||
@pytest.mark.windows_whitelisted
|
||||
class RegTest(ModuleCase, SaltReturnAssertsMixin):
|
||||
"""
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
:codeauthor: Jayesh Kariya <jayeshk@saltstack.com>
|
||||
"""
|
||||
|
||||
|
||||
import salt.modules.win_groupadd as win_groupadd
|
||||
import salt.utils.win_functions
|
||||
from tests.support.helpers import TstSuiteLoggingHandler
|
||||
|
|
|
@ -11,9 +11,10 @@ from tests.support.mock import MagicMock, patch
|
|||
from tests.support.unit import TestCase, skipIf
|
||||
|
||||
try:
|
||||
WINAPI = True
|
||||
import pywintypes
|
||||
import win32serviceutil
|
||||
|
||||
WINAPI = True
|
||||
except ImportError:
|
||||
WINAPI = False
|
||||
|
||||
|
|
|
@ -2,10 +2,11 @@
|
|||
:codeauthor: Rahul Handay <rahulha@saltstack.com>
|
||||
"""
|
||||
|
||||
|
||||
import types
|
||||
from datetime import datetime
|
||||
|
||||
import pytest
|
||||
|
||||
import salt.modules.win_system as win_system
|
||||
import salt.utils.platform
|
||||
import salt.utils.stringutils
|
||||
|
@ -123,7 +124,7 @@ class MockWMI_BIOS:
|
|||
|
||||
|
||||
@skipIf(not HAS_WMI, "WMI only available on Windows")
|
||||
@skipIf(not salt.utils.platform.is_windows(), "System is not Windows")
|
||||
@pytest.mark.skip_unless_on_windows
|
||||
class WinSystemTestCase(TestCase, LoaderModuleMockMixin):
|
||||
"""
|
||||
Test cases for salt.modules.win_system
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
import pytest
|
||||
|
||||
import salt.modules.win_task as win_task
|
||||
import salt.utils.platform
|
||||
from tests.support.unit import TestCase, skipIf
|
||||
from tests.support.unit import TestCase
|
||||
|
||||
|
||||
@skipIf(not salt.utils.platform.is_windows(), "System is not Windows")
|
||||
@pytest.mark.skip_unless_on_windows
|
||||
@pytest.mark.destructive_test
|
||||
class WinTaskTestCase(TestCase):
|
||||
"""
|
||||
|
|
|
@ -2,16 +2,16 @@
|
|||
Test the win_wusa execution module
|
||||
"""
|
||||
|
||||
import pytest
|
||||
|
||||
import salt.modules.win_wusa as win_wusa
|
||||
import salt.utils.platform
|
||||
from salt.exceptions import CommandExecutionError
|
||||
from tests.support.mixins import LoaderModuleMockMixin
|
||||
from tests.support.mock import MagicMock, patch
|
||||
from tests.support.unit import TestCase, skipIf
|
||||
from tests.support.unit import TestCase
|
||||
|
||||
|
||||
@skipIf(not salt.utils.platform.is_windows(), "System is not Windows")
|
||||
@pytest.mark.skip_unless_on_windows
|
||||
class WinWusaTestCase(TestCase, LoaderModuleMockMixin):
|
||||
"""
|
||||
test the functions in the win_wusa execution module
|
||||
|
|
|
@ -10,6 +10,8 @@ import os
|
|||
import platform
|
||||
import sys
|
||||
|
||||
import pytest
|
||||
|
||||
import salt.utils.platform
|
||||
|
||||
# salt libs
|
||||
|
@ -121,7 +123,7 @@ class RSAX931Test(TestCase):
|
|||
msg = verifier.verify(RSAX931Test.hello_world_sig)
|
||||
self.assertEqual(RSAX931Test.hello_world, msg)
|
||||
|
||||
@skipIf(not salt.utils.platform.is_windows(), "Host OS is not Windows.")
|
||||
@pytest.mark.skip_unless_on_windows
|
||||
def test_find_libcrypto_win32(self):
|
||||
"""
|
||||
Test _find_libcrypto on Windows hosts.
|
||||
|
|
|
@ -1,13 +1,17 @@
|
|||
"""
|
||||
Test win_chcp
|
||||
"""
|
||||
import pytest
|
||||
|
||||
from salt.exceptions import CodePageError
|
||||
from salt.utils import platform, win_chcp
|
||||
from tests.support.unit import TestCase, skipIf
|
||||
from salt.utils import win_chcp
|
||||
from tests.support.unit import TestCase
|
||||
|
||||
pytestmark = [
|
||||
pytest.mark.skip_unless_on_windows,
|
||||
]
|
||||
|
||||
|
||||
@skipIf(not platform.is_windows(), "Windows only tests!")
|
||||
class CHCPTest(TestCase):
|
||||
"""
|
||||
Test case for salt.utils.win_chcp
|
||||
|
|
|
@ -1,10 +1,14 @@
|
|||
import salt.utils.platform
|
||||
import pytest
|
||||
|
||||
import salt.utils.win_dotnet as win_dotnet
|
||||
from tests.support.mock import MagicMock, patch
|
||||
from tests.support.unit import TestCase, skipIf
|
||||
from tests.support.unit import TestCase
|
||||
|
||||
pytestmark = [
|
||||
pytest.mark.skip_unless_on_windows,
|
||||
]
|
||||
|
||||
|
||||
@skipIf(not salt.utils.platform.is_windows(), "System is not Windows")
|
||||
class WinDotNetTestCase(TestCase):
|
||||
"""
|
||||
Test cases for salt.utils.win_dotnet
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import salt.utils.platform
|
||||
import pytest
|
||||
|
||||
import salt.utils.win_functions as win_functions
|
||||
from tests.support.mock import MagicMock, patch
|
||||
from tests.support.unit import TestCase, skipIf
|
||||
|
@ -52,21 +53,21 @@ class WinFunctionsTestCase(TestCase):
|
|||
|
||||
self.assertEqual(encoded, '^"C:\\Some Path\\With Spaces^"')
|
||||
|
||||
@skipIf(not salt.utils.platform.is_windows(), "WinDLL only available on Windows")
|
||||
@pytest.mark.skip_unless_on_windows
|
||||
def test_broadcast_setting_change(self):
|
||||
"""
|
||||
Test to rehash the Environment variables
|
||||
"""
|
||||
self.assertTrue(win_functions.broadcast_setting_change())
|
||||
|
||||
@skipIf(not salt.utils.platform.is_windows(), "WinDLL only available on Windows")
|
||||
@pytest.mark.skip_unless_on_windows
|
||||
def test_get_user_groups(self):
|
||||
groups = ["Administrators", "Users"]
|
||||
with patch("win32net.NetUserGetLocalGroups", return_value=groups):
|
||||
ret = win_functions.get_user_groups("Administrator")
|
||||
self.assertListEqual(groups, ret)
|
||||
|
||||
@skipIf(not salt.utils.platform.is_windows(), "WinDLL only available on Windows")
|
||||
@pytest.mark.skip_unless_on_windows
|
||||
def test_get_user_groups_sid(self):
|
||||
groups = ["Administrators", "Users"]
|
||||
expected = ["S-1-5-32-544", "S-1-5-32-545"]
|
||||
|
@ -74,14 +75,14 @@ class WinFunctionsTestCase(TestCase):
|
|||
ret = win_functions.get_user_groups("Administrator", sid=True)
|
||||
self.assertListEqual(expected, ret)
|
||||
|
||||
@skipIf(not salt.utils.platform.is_windows(), "WinDLL only available on Windows")
|
||||
@pytest.mark.skip_unless_on_windows
|
||||
def test_get_user_groups_system(self):
|
||||
groups = ["SYSTEM"]
|
||||
with patch("win32net.NetUserGetLocalGroups", return_value=groups):
|
||||
ret = win_functions.get_user_groups("SYSTEM")
|
||||
self.assertListEqual(groups, ret)
|
||||
|
||||
@skipIf(not salt.utils.platform.is_windows(), "WinDLL only available on Windows")
|
||||
@pytest.mark.skip_unless_on_windows
|
||||
@skipIf(not HAS_WIN32, "Requires pywin32 libraries")
|
||||
def test_get_user_groups_unavailable_dc(self):
|
||||
groups = ["Administrators", "Users"]
|
||||
|
@ -92,7 +93,7 @@ class WinFunctionsTestCase(TestCase):
|
|||
ret = win_functions.get_user_groups("Administrator")
|
||||
self.assertListEqual(groups, ret)
|
||||
|
||||
@skipIf(not salt.utils.platform.is_windows(), "WinDLL only available on Windows")
|
||||
@pytest.mark.skip_unless_on_windows
|
||||
@skipIf(not HAS_WIN32, "Requires pywin32 libraries")
|
||||
def test_get_user_groups_unknown_dc(self):
|
||||
groups = ["Administrators", "Users"]
|
||||
|
@ -103,7 +104,7 @@ class WinFunctionsTestCase(TestCase):
|
|||
ret = win_functions.get_user_groups("Administrator")
|
||||
self.assertListEqual(groups, ret)
|
||||
|
||||
@skipIf(not salt.utils.platform.is_windows(), "WinDLL only available on Windows")
|
||||
@pytest.mark.skip_unless_on_windows
|
||||
@skipIf(not HAS_WIN32, "Requires pywin32 libraries")
|
||||
def test_get_user_groups_missing_permission(self):
|
||||
groups = ["Administrators", "Users"]
|
||||
|
@ -114,7 +115,7 @@ class WinFunctionsTestCase(TestCase):
|
|||
ret = win_functions.get_user_groups("Administrator")
|
||||
self.assertListEqual(groups, ret)
|
||||
|
||||
@skipIf(not salt.utils.platform.is_windows(), "WinDLL only available on Windows")
|
||||
@pytest.mark.skip_unless_on_windows
|
||||
@skipIf(not HAS_WIN32, "Requires pywin32 libraries")
|
||||
def test_get_user_groups_error(self):
|
||||
win_error = WinError()
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
import salt.utils.platform
|
||||
import pytest
|
||||
|
||||
import salt.utils.win_network as win_network
|
||||
from tests.support.mock import MagicMock, patch
|
||||
from tests.support.unit import TestCase, skipIf
|
||||
from tests.support.unit import TestCase
|
||||
|
||||
|
||||
class PhysicalAddress:
|
||||
|
@ -39,7 +40,7 @@ class Interface:
|
|||
return self.PhysicalAddress
|
||||
|
||||
|
||||
@skipIf(not salt.utils.platform.is_windows(), "System is not Windows")
|
||||
@pytest.mark.skip_unless_on_windows
|
||||
class WinNetworkTestCase(TestCase):
|
||||
def setUp(self):
|
||||
self.mock_ip_base = MagicMock(
|
||||
|
|
|
@ -4,12 +4,13 @@
|
|||
|
||||
import sys
|
||||
|
||||
import salt.utils.platform
|
||||
import pytest
|
||||
|
||||
import salt.utils.win_osinfo as win_osinfo
|
||||
from tests.support.unit import TestCase, skipIf
|
||||
from tests.support.unit import TestCase
|
||||
|
||||
|
||||
@skipIf(not salt.utils.platform.is_windows(), "Requires Windows")
|
||||
@pytest.mark.skip_unless_on_windows
|
||||
class WinOsInfo(TestCase):
|
||||
"""
|
||||
Test cases for salt/utils/win_osinfo.py
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
import pytest
|
||||
|
||||
import salt.utils.platform
|
||||
import salt.utils.win_pdh as win_pdh
|
||||
from tests.support.mock import patch
|
||||
from tests.support.unit import TestCase, skipIf
|
||||
|
@ -14,7 +13,7 @@ except ImportError:
|
|||
|
||||
|
||||
@skipIf(not HAS_WIN32, "Requires pywin32")
|
||||
@skipIf(not salt.utils.platform.is_windows(), "System is not Windows")
|
||||
@pytest.mark.skip_unless_on_windows
|
||||
class WinPdhTestCase(TestCase):
|
||||
@pytest.mark.slow_test
|
||||
def test_list_objects(self):
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import salt.utils.platform
|
||||
from tests.support.unit import TestCase, skipIf
|
||||
import pytest
|
||||
|
||||
from tests.support.unit import TestCase
|
||||
|
||||
try:
|
||||
import salt.utils.win_service as win_service
|
||||
|
@ -18,7 +19,7 @@ class WinServiceImportTestCase(TestCase):
|
|||
)
|
||||
|
||||
|
||||
@skipIf(not salt.utils.platform.is_windows(), "Only test on Windows systems")
|
||||
@pytest.mark.skip_unless_on_windows
|
||||
class WinServiceTestCase(TestCase):
|
||||
"""
|
||||
Test cases for salt.utils.win_service
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
import os
|
||||
|
||||
import salt.utils.platform
|
||||
import pytest
|
||||
|
||||
from tests.support.mock import patch
|
||||
from tests.support.unit import TestCase, skipIf
|
||||
from tests.support.unit import TestCase
|
||||
|
||||
try:
|
||||
import salt.utils.win_system as win_system
|
||||
|
@ -22,7 +23,7 @@ class WinSystemImportTestCase(TestCase):
|
|||
)
|
||||
|
||||
|
||||
@skipIf(not salt.utils.platform.is_windows(), "Only test on Windows systems")
|
||||
@pytest.mark.skip_unless_on_windows
|
||||
class WinSystemTestCase(TestCase):
|
||||
"""
|
||||
Test cases for salt.utils.win_system
|
||||
|
|
Loading…
Add table
Reference in a new issue