def test_release_leader_catch_rediserror(): lock = mock.Mock() redcli = mock.Mock() redcli.delete.side_effect = redis.exceptions.RedisError assert release_leader(lock, redcli) is False assert lock.release.call_count == 1 redcli.delete.assert_called_once_with('tscached:shadow_server')
def test_release_leader_catch_redlockerror(): lock = mock.Mock() redcli = mock.Mock() lock.release.side_effect = redlock.RedLockError assert release_leader(lock, redcli) is False assert lock.release.call_count == 1 assert redcli.delete.call_count == 0
def test_release_leader_release_ok(): lock = mock.Mock() redcli = mock.Mock() assert release_leader(lock, redcli) is True assert lock.release.call_count == 1 redcli.delete.assert_called_once_with('tscached:shadow_server')