def test_lock(): """ Test to block state execution until you are able to get the lock """ ret = {"name": "salt", "changes": {}, "result": True, "comment": ""} with patch.dict(zk_concurrency.__opts__, {"test": True}): ret.update({"comment": "Attempt to acquire lock", "result": None}) assert zk_concurrency.lock("salt", "dude") == ret with patch.dict(zk_concurrency.__opts__, {"test": False}): mock = MagicMock(return_value=True) with patch.dict(zk_concurrency.__salt__, {"zk_concurrency.lock": mock}): ret.update({"comment": "lock acquired", "result": True}) assert zk_concurrency.lock("salt", "dude", "stack") == ret
def test_lock(self): ''' Test to block state execution until you are able to get the lock ''' ret = {'name': 'salt', 'changes': {}, 'result': True, 'comment': ''} with patch.dict(zk_concurrency.__opts__, {"test": True}): ret.update({'comment': 'Attempt to acquire lock', 'result': None}) self.assertDictEqual(zk_concurrency.lock('salt', 'dude'), ret) with patch.dict(zk_concurrency.__opts__, {"test": False}): mock = MagicMock(return_value=True) with patch.dict(zk_concurrency.__salt__, {"zk_concurrency.lock": mock}): ret.update({'comment': 'lock acquired', 'result': True}) self.assertDictEqual( zk_concurrency.lock('salt', 'dude', 'stack'), ret)
def test_lock(self): ''' Test to block state execution until you are able to get the lock ''' ret = {'name': 'salt', 'changes': {}, 'result': True, 'comment': ''} with patch.dict(zk_concurrency.__opts__, {"test": True}): ret.update({'comment': 'Attempt to acquire lock', 'result': None}) self.assertDictEqual(zk_concurrency.lock('salt', 'dude'), ret) with patch.dict(zk_concurrency.__opts__, {"test": False}): mock = MagicMock(return_value=True) with patch.dict(zk_concurrency.__salt__, {"zk_concurrency.lock": mock}): ret.update({'comment': 'lock acquired', 'result': True}) self.assertDictEqual(zk_concurrency.lock('salt', 'dude', 'stack'), ret)