1
0

test_pdbedit.py 1.1 KB

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