diff options
author | dvora-h <67596500+dvora-h@users.noreply.github.com> | 2022-05-31 15:47:24 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-31 15:47:24 +0300 |
commit | 04bc576679e9fedb24a0548521d80fe81c91e2ec (patch) | |
tree | 6f1aec5c276393ac1917e372ac39858e9a48b3d5 /tests/test_function.py | |
parent | 4a73d85c78ce0ca36e5100b7ee0047b773cec23f (diff) | |
download | redis-py-04bc576679e9fedb24a0548521d80fe81c91e2ec.tar.gz |
Fix tests for Redis 7 (#2182)
* fix tests
* async
Diffstat (limited to 'tests/test_function.py')
-rw-r--r-- | tests/test_function.py | 51 |
1 files changed, 25 insertions, 26 deletions
diff --git a/tests/test_function.py b/tests/test_function.py index 70f6b19..7ce66a3 100644 --- a/tests/test_function.py +++ b/tests/test_function.py @@ -22,10 +22,10 @@ class TestFunction: def reset_functions(self, r): r.function_flush() + @pytest.mark.onlynoncluster def test_function_load(self, r): - print("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!") - assert lib == r.function_load(f"#!{engine} name={lib} \n {function}") - assert lib == r.function_load( + assert b"mylib" == r.function_load(f"#!{engine} name={lib} \n {function}") + assert b"mylib" == r.function_load( f"#!{engine} name={lib} \n {function}", replace=True ) with pytest.raises(ResponseError): @@ -37,15 +37,14 @@ class TestFunction: r.function_load(f"#!{engine} name={lib} \n {set_function}") with pytest.raises(ResponseError): r.function_load(f"#!{engine} name={lib} \n {set_function}") - assert r.fcall("set", 1, "foo", "bar") == "OK" + assert r.fcall("set", 1, "foo", "bar") == b"OK" assert r.function_delete("mylib") with pytest.raises(ResponseError): r.fcall("set", 1, "foo", "bar") - assert lib == r.function_load(f"#!{engine} name={lib} \n {set_function}") def test_function_flush(self, r): r.function_load(f"#!{engine} name={lib} \n {function}") - assert r.fcall("myfunc", 0, "hello") == "hello" + assert r.fcall("myfunc", 0, "hello") == b"hello" assert r.function_flush() with pytest.raises(ResponseError): r.fcall("myfunc", 0, "hello") @@ -57,19 +56,19 @@ class TestFunction: r.function_load(f"#!{engine} name={lib} \n {function}") res = [ [ - "library_name", - "mylib", - "engine", - "LUA", - "functions", - [["name", "myfunc", "description", None, "flags", ["no-writes"]]], + b"library_name", + b"mylib", + b"engine", + b"LUA", + b"functions", + [[b"name", b"myfunc", b"description", None, b"flags", [b"no-writes"]]], ] ] assert r.function_list() == res assert r.function_list(library="*lib") == res assert ( r.function_list(withcode=True)[0][7] - == f"#!{engine} name={lib} \n {function}" + == f"#!{engine} name={lib} \n {function}".encode() ) @pytest.mark.onlycluster @@ -77,12 +76,12 @@ class TestFunction: r.function_load(f"#!{engine} name={lib} \n {function}") function_list = [ [ - "library_name", - "mylib", - "engine", - "LUA", - "functions", - [["name", "myfunc", "description", None, "flags", ["no-writes"]]], + b"library_name", + b"mylib", + b"engine", + b"LUA", + b"functions", + [[b"name", b"myfunc", b"description", None, b"flags", [b"no-writes"]]], ] ] primaries = r.get_primaries() @@ -94,20 +93,20 @@ class TestFunction: node = primaries[0].name assert ( r.function_list(withcode=True)[node][0][7] - == f"#!{engine} name={lib} \n {function}" + == f"#!{engine} name={lib} \n {function}".encode() ) def test_fcall(self, r): r.function_load(f"#!{engine} name={lib} \n {set_function}") r.function_load(f"#!{engine} name={lib2} \n {get_function}") - assert r.fcall("set", 1, "foo", "bar") == "OK" - assert r.fcall("get", 1, "foo") == "bar" + assert r.fcall("set", 1, "foo", "bar") == b"OK" + assert r.fcall("get", 1, "foo") == b"bar" with pytest.raises(ResponseError): r.fcall("myfunc", 0, "hello") def test_fcall_ro(self, r): r.function_load(f"#!{engine} name={lib} \n {function}") - assert r.fcall_ro("myfunc", 0, "hello") == "hello" + assert r.fcall_ro("myfunc", 0, "hello") == b"hello" r.function_load(f"#!{engine} name={lib2} \n {set_function}") with pytest.raises(ResponseError): r.fcall_ro("set", 1, "foo", "bar") @@ -115,14 +114,14 @@ class TestFunction: def test_function_dump_restore(self, r): r.function_load(f"#!{engine} name={lib} \n {set_function}") payload = r.function_dump() - assert r.fcall("set", 1, "foo", "bar") == "OK" + assert r.fcall("set", 1, "foo", "bar") == b"OK" r.function_delete("mylib") with pytest.raises(ResponseError): r.fcall("set", 1, "foo", "bar") assert r.function_restore(payload) - assert r.fcall("set", 1, "foo", "bar") == "OK" + assert r.fcall("set", 1, "foo", "bar") == b"OK" r.function_load(f"#!{engine} name={lib2} \n {get_function}") - assert r.fcall("get", 1, "foo") == "bar" + assert r.fcall("get", 1, "foo") == b"bar" r.function_delete("mylib") assert r.function_restore(payload, "FLUSH") with pytest.raises(ResponseError): |