1
0

test_pdbedit.py 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. # -*- coding: utf-8 -*-
  2. # Import python libs
  3. from __future__ import absolute_import, print_function, unicode_literals
  4. # Import Salt Libs
  5. import salt.states.pdbedit as pdbedit
  6. import salt.modules.pdbedit as pdbedit_mod
  7. # Import Salt Testing Libs
  8. from tests.support.mixins import LoaderModuleMockMixin
  9. from tests.support.unit import TestCase
  10. from tests.support.mock import patch, MagicMock
  11. class PdbeditTestCase(TestCase, LoaderModuleMockMixin):
  12. '''
  13. TestCase for salt.states.pdbedit module
  14. '''
  15. def setup_loader_modules(self):
  16. return {pdbedit: {},
  17. pdbedit_mod: {}}
  18. def test_generate_absent(self):
  19. '''
  20. Test salt.states.pdbedit.absent when
  21. user is already absent
  22. '''
  23. name = 'testname'
  24. cmd_ret = {'pid': 13172, 'retcode': 0, 'stdout': '', 'stderr': ''}
  25. with patch.dict(pdbedit.__salt__, {'pdbedit.list':
  26. pdbedit_mod.list_users}):
  27. with patch.dict(pdbedit_mod.__salt__, {'cmd.run_all':
  28. MagicMock(return_value=cmd_ret)}):
  29. ret = pdbedit.absent(name)
  30. assert ret['comment'] == 'account {0} is absent'.format(name)