# 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
        assert await r.script_exists(sha) == [False]
        await r.script_load(multiply_script)
        assert await r.script_exists(sha) == [True]

    @pytest.mark.asyncio()
    async def test_script_object(self, r):
        await r.set('a', 2)
        multiply = r.register_script(multiply_script)
        assert multiply.sha == '29cdf3e36c89fa05d7e6d6b9734b342ab15c9ea7'
        # test evalsha fail -> script load + retry
        assert await multiply.execute(keys=['a'], args=[3]) == 6
        assert multiply.sha
        assert await r.script_exists(multiply.sha) == [True]
        # 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]

# 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

        assert await r.script_exists(sha) == [False]
        await r.script_load(multiply_script)
        assert await r.script_exists(sha) == [True]

    @pytest.mark.asyncio()
    async def test_script_object(self, r):
        await r.set('a', 2)
        multiply = r.register_script(multiply_script)
        assert multiply.sha == '29cdf3e36c89fa05d7e6d6b9734b342ab15c9ea7'
        # test evalsha fail -> script load + retry
        assert await multiply.execute(keys=['a'], args=[3]) == 6
        assert multiply.sha
        assert await r.script_exists(multiply.sha) == [True]
        # 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]