1
0

test_win_osinfo.py 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. # -*- coding: utf-8 -*-
  2. """
  3. :codeauthor: Shane Lee <slee@saltstack.com>
  4. """
  5. # Import Python Libs
  6. from __future__ import absolute_import, print_function, unicode_literals
  7. import sys
  8. import salt.utils.platform
  9. # Import Salt Libs
  10. import salt.utils.win_osinfo as win_osinfo
  11. # Import 3rd Party Libs
  12. from salt.ext import six
  13. # Import Salt Testing Libs
  14. from tests.support.unit import TestCase, skipIf
  15. @skipIf(not salt.utils.platform.is_windows(), "Requires Windows")
  16. class WinOsInfo(TestCase):
  17. """
  18. Test cases for salt/utils/win_osinfo.py
  19. """
  20. def test_get_os_version_info(self):
  21. sys_info = sys.getwindowsversion()
  22. get_info = win_osinfo.get_os_version_info()
  23. self.assertEqual(sys_info.major, int(get_info["MajorVersion"]))
  24. self.assertEqual(sys_info.minor, int(get_info["MinorVersion"]))
  25. self.assertEqual(sys_info.platform, int(get_info["PlatformID"]))
  26. self.assertEqual(sys_info.build, int(get_info["BuildNumber"]))
  27. # Platform ID is the reason for this function
  28. # Since we can't get the actual value another way, we will just check
  29. # that it exists and is a number
  30. self.assertIn("PlatformID", get_info)
  31. self.assertTrue(isinstance(get_info["BuildNumber"], six.integer_types))
  32. def test_get_join_info(self):
  33. join_info = win_osinfo.get_join_info()
  34. self.assertIn("Domain", join_info)
  35. self.assertIn("DomainType", join_info)
  36. valid_types = ["Unknown", "Unjoined", "Workgroup", "Domain"]
  37. self.assertIn(join_info["DomainType"], valid_types)