# Path: aredis/exceptions.py
# class RedisClusterException(Exception):
#     pass
# 
# class NoScriptError(ResponseError):
#     pass
# 
# class ResponseError(RedisError):
#     pass
# 
# Path: aredis/utils.py
# def b(x):
#     return x.encode('latin-1') if not isinstance(x, bytes) else x


import asyncio
import pytest
from aredis.exceptions import RedisClusterException, NoScriptError, ResponseError
from aredis.utils import b
        # test first evalsha
        assert await multiply.execute(keys=['a'], args=[3]) == 6

    @pytest.mark.asyncio(forbid_global_loop=True)
    @pytest.mark.xfail(reason="Not Yet Implemented")
    async def test_script_object_in_pipeline(self, r):
        multiply = await r.register_script(multiply_script)
        assert not multiply.sha
        pipe = r.pipeline()
        await pipe.set('a', 2)
        await pipe.get('a')
        multiply(keys=['a'], args=[3], client=pipe)
        # even though the pipeline wasn't executed yet, we made sure the
        # script was loaded and got a valid sha
        assert multiply.sha
        assert await r.script_exists(multiply.sha) == [True]
        # [SET worked, GET 'a', result of multiple script]
        assert await pipe.execute() == [True, b('2'), 6]

        # purge the script from redis's cache and re-run the pipeline
        # the multiply script object knows it's sha, so it shouldn't get
        # reloaded until pipe.execute()
        await r.script_flush()
        pipe = await r.pipeline()
        await pipe.set('a', 2)
        await pipe.get('a')
        assert multiply.sha
        multiply(keys=['a'], args=[3], client=pipe)
        assert await r.script_exists(multiply.sha) == [False]
        # [SET worked, GET 'a', result of multiple script]

# Path: aredis/exceptions.py
# class RedisClusterException(Exception):
#     pass
# 
# class NoScriptError(ResponseError):
#     pass
# 
# class ResponseError(RedisError):
#     pass
# 
# Path: aredis/utils.py
# def b(x):
#     return x.encode('latin-1') if not isinstance(x, bytes) else x


# Path: tests/cluster/test_scripting.py
import asyncio
import pytest
from aredis.exceptions import RedisClusterException, NoScriptError, ResponseError
from aredis.utils import b

        # test first evalsha
        assert await multiply.execute(keys=['a'], args=[3]) == 6

    @pytest.mark.asyncio(forbid_global_loop=True)
    @pytest.mark.xfail(reason="Not Yet Implemented")
    async def test_script_object_in_pipeline(self, r):
        multiply = await r.register_script(multiply_script)
        assert not multiply.sha
        pipe = r.pipeline()
        await pipe.set('a', 2)
        await pipe.get('a')
        multiply(keys=['a'], args=[3], client=pipe)
        # even though the pipeline wasn't executed yet, we made sure the
        # script was loaded and got a valid sha
        assert multiply.sha
        assert await r.script_exists(multiply.sha) == [True]
        # [SET worked, GET 'a', result of multiple script]
        assert await pipe.execute() == [True, b('2'), 6]

        # purge the script from redis's cache and re-run the pipeline
        # the multiply script object knows it's sha, so it shouldn't get
        # reloaded until pipe.execute()
        await r.script_flush()
        pipe = await r.pipeline()
        await pipe.set('a', 2)
        await pipe.get('a')
        assert multiply.sha
        multiply(keys=['a'], args=[3], client=pipe)
        assert await r.script_exists(multiply.sha) == [False]
        # [SET worked, GET 'a', result of multiple script]

        assert await pipe.execute() == [True, b('2'), 6]