def test_present(self):
        name = 'web01'

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

        mock = MagicMock(side_effect=[False, True, True, True, True, True,
                                      True])
        mock_t = MagicMock(side_effect=[None, True, 'frozen', 'frozen',
                                        'stopped', 'running', 'running'])
        with patch.dict(lxc.__salt__, {'lxc.exists': mock,
                                       'lxc.state': mock_t}):
            comt = ("Clone source 'True' does not exist")
            ret.update({'comment': comt})
            self.assertDictEqual(lxc.present(name, clone_from=True), ret)

            with patch.dict(lxc.__opts__, {'test': True}):
                comt = ("Container 'web01' will be cloned from True")
                ret.update({'comment': comt, 'result': None})
                self.assertDictEqual(lxc.present(name, clone_from=True), ret)

                comt = ("Container 'web01' already exists")
                ret.update({'comment': comt, 'result': True})
                self.assertDictEqual(lxc.present(name, clone_from=True), ret)

                comt = ("Container 'web01' would be unfrozen")
                ret.update({'comment': comt, 'result': None})
                self.assertDictEqual(lxc.present(name, running=True,
                                                 clone_from=True), ret)

                comt = ('Container \'{0}\' would be stopped'.format(name))
                ret.update({'comment': comt, 'result': None})
                self.assertDictEqual(lxc.present(name, running=False,
                                                 clone_from=True), ret)

                comt = ("Container 'web01' already exists and is stopped")
                ret.update({'comment': comt, 'result': True})
                self.assertDictEqual(lxc.present(name, running=False,
                                                 clone_from=True), ret)

            with patch.dict(lxc.__opts__, {'test': False}):
                comt = ("Container 'web01' already exists")
                ret.update({'comment': comt, 'result': True})
                self.assertDictEqual(lxc.present(name, clone_from=True), ret)

    # 'absent' function tests: 1
Get the connected YubiKey's version as a string.
dataset/ETHPy150Open saltstack/salt/tests/unit/states/lxc_test.py/LxcTestCase.test_present--crossover with--dataset/ETHPy150Open Yubico/python-yubico/yubico/yubikey_base.py/YubiKey.version