test_win_disk.py 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. # -*- coding: utf-8 -*-
  2. '''
  3. :codeauthor: Jayesh Kariya <jayeshk@saltstack.com>
  4. '''
  5. # Import Python Libs
  6. from __future__ import absolute_import, unicode_literals, print_function
  7. # Import Salt Testing Libs
  8. from tests.support.mixins import LoaderModuleMockMixin
  9. from tests.support.unit import TestCase
  10. # Import Salt Libs
  11. import salt.modules.win_disk as win_disk
  12. class MockKernel32(object):
  13. '''
  14. Mock windll class
  15. '''
  16. def __init__(self):
  17. pass
  18. @staticmethod
  19. def GetLogicalDrives():
  20. '''
  21. Mock GetLogicalDrives method
  22. '''
  23. return 1
  24. class MockWindll(object):
  25. '''
  26. Mock windll class
  27. '''
  28. def __init__(self):
  29. self.kernel32 = MockKernel32()
  30. class MockCtypes(object):
  31. '''
  32. Mock ctypes class
  33. '''
  34. def __init__(self):
  35. self.windll = MockWindll()
  36. class WinDiskTestCase(TestCase, LoaderModuleMockMixin):
  37. '''
  38. Test cases for salt.modules.win_disk
  39. '''
  40. def setup_loader_modules(self):
  41. return {win_disk: {'ctypes': MockCtypes()}}
  42. # 'usage' function tests: 1
  43. def test_usage(self):
  44. '''
  45. Test if it return usage information for volumes mounted on this minion.
  46. '''
  47. self.assertDictEqual(win_disk.usage(),
  48. {'A:\\': {'available': None,
  49. '1K-blocks': None,
  50. 'used': None,
  51. 'capacity': None,
  52. 'filesystem': 'A:\\'}})