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
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)
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)