1
0

test_win_osinfo.py 1.6 KB

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