예제 #1
0
def test_unlock():
    """
    Test to remove lease from semaphore
    """
    ret = {"name": "salt", "changes": {}, "result": True, "comment": ""}

    with patch.dict(zk_concurrency.__opts__, {"test": True}):
        ret.update({"comment": "Released lock if it is here", "result": None})
        assert zk_concurrency.unlock("salt") == ret

    with patch.dict(zk_concurrency.__opts__, {"test": False}):
        mock = MagicMock(return_value=True)
        with patch.dict(zk_concurrency.__salt__, {"zk_concurrency.unlock": mock}):
            ret.update({"comment": "", "result": True})
            assert zk_concurrency.unlock("salt", identifier="stack") == ret
예제 #2
0
    def test_unlock(self):
        '''
            Test to remove lease from semaphore
        '''
        ret = {'name': 'salt', 'changes': {}, 'result': True, 'comment': ''}

        with patch.dict(zk_concurrency.__opts__, {"test": True}):
            ret.update({
                'comment': 'Released lock if it is here',
                'result': None
            })
            self.assertDictEqual(zk_concurrency.unlock('salt'), ret)

        with patch.dict(zk_concurrency.__opts__, {"test": False}):
            mock = MagicMock(return_value=True)
            with patch.dict(zk_concurrency.__salt__,
                            {"zk_concurrency.unlock": mock}):
                ret.update({'comment': '', 'result': True})
                self.assertDictEqual(
                    zk_concurrency.unlock('salt', identifier='stack'), ret)
예제 #3
0
    def test_unlock(self):
        '''
            Test to remove lease from semaphore
        '''
        ret = {'name': 'salt',
               'changes': {},
               'result': True,
               'comment': ''}

        with patch.dict(zk_concurrency.__opts__, {"test": True}):
            ret.update({'comment': 'Released lock if it is here',
                        'result': None})
            self.assertDictEqual(zk_concurrency.unlock('salt'), ret)

        with patch.dict(zk_concurrency.__opts__, {"test": False}):
            mock = MagicMock(return_value=True)
            with patch.dict(zk_concurrency.__salt__,
                            {"zk_concurrency.unlock": mock}):
                ret.update({'comment': '', 'result': True})
                self.assertDictEqual(zk_concurrency.unlock('salt',
                                                           identifier='stack'),
                                     ret)