def test_user_absent(self):
        name = 'salt'

        ret = {'name': name,
               'result': True,
               'comment': '',
               'changes': {}}

        mock = MagicMock(side_effect=[[], [5], [5]])
        mock_bool = MagicMock(return_value=True)
        with patch.dict(ipmi.__salt__, {'ipmi.get_name_uids': mock,
                                        'ipmi.delete_user': mock_bool}):
            comt = ('user already absent')
            ret.update({'comment': comt})
            self.assertDictEqual(ipmi.user_absent(name), ret)

            with patch.dict(ipmi.__opts__, {'test': True}):
                comt = ('would delete user(s)')
                ret.update({'comment': comt, 'result': None,
                            'changes': {'delete': [5]}})
                self.assertDictEqual(ipmi.user_absent(name), ret)

            with patch.dict(ipmi.__opts__, {'test': False}):
                comt = ('user(s) removed')
                ret.update({'comment': comt, 'result': False,
                            'changes': {'new': 'None', 'old': [5]}})
                self.assertDictEqual(ipmi.user_absent(name), ret)
Test to delete all user (uid) records having the matching name.
dataset/ETHPy150Open saltstack/salt/tests/unit/states/ipmi_test.py/IpmiTestCase.test_user_absent