test_win_disk.py 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. # -*- coding: utf-8 -*-
  2. """
  3. :codeauthor: Jayesh Kariya <jayeshk@saltstack.com>
  4. """
  5. # Import Python Libs
  6. from __future__ import absolute_import, print_function, unicode_literals
  7. # Import Salt Libs
  8. import salt.modules.win_disk as win_disk
  9. # Import Salt Testing Libs
  10. from tests.support.mixins import LoaderModuleMockMixin
  11. from tests.support.unit import TestCase
  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(
  48. win_disk.usage(),
  49. {
  50. "A:\\": {
  51. "available": None,
  52. "1K-blocks": None,
  53. "used": None,
  54. "capacity": None,
  55. "filesystem": "A:\\",
  56. }
  57. },
  58. )