15
15
@skip_if_server_version_lt ("7.0.0" )
16
16
class TestFunction :
17
17
@pytest .fixture (autouse = True )
18
- def reset_functions (self , unstable_r ):
19
- unstable_r .function_flush ()
18
+ def reset_functions (self , r ):
19
+ r .function_flush ()
20
20
21
- def test_function_load (self , unstable_r ):
22
- assert unstable_r .function_load ("Lua" , "mylib" , function )
23
- assert unstable_r .function_load ("Lua" , "mylib" , function , replace = True )
21
+ def test_function_load (self , r ):
22
+ assert r .function_load ("Lua" , "mylib" , function )
23
+ assert r .function_load ("Lua" , "mylib" , function , replace = True )
24
24
with pytest .raises (ResponseError ):
25
- unstable_r .function_load ("Lua" , "mylib" , function )
25
+ r .function_load ("Lua" , "mylib" , function )
26
26
with pytest .raises (ResponseError ):
27
- unstable_r .function_load ("Lua" , "mylib2" , function )
27
+ r .function_load ("Lua" , "mylib2" , function )
28
28
29
- def test_function_delete (self , unstable_r ):
30
- unstable_r .function_load ("Lua" , "mylib" , set_function )
29
+ def test_function_delete (self , r ):
30
+ r .function_load ("Lua" , "mylib" , set_function )
31
31
with pytest .raises (ResponseError ):
32
- unstable_r .function_load ("Lua" , "mylib" , set_function )
33
- assert unstable_r .fcall ("set" , 1 , "foo" , "bar" ) == "OK"
34
- assert unstable_r .function_delete ("mylib" )
32
+ r .function_load ("Lua" , "mylib" , set_function )
33
+ assert r .fcall ("set" , 1 , "foo" , "bar" ) == "OK"
34
+ assert r .function_delete ("mylib" )
35
35
with pytest .raises (ResponseError ):
36
- unstable_r .fcall ("set" , 1 , "foo" , "bar" )
37
- assert unstable_r .function_load ("Lua" , "mylib" , set_function )
36
+ r .fcall ("set" , 1 , "foo" , "bar" )
37
+ assert r .function_load ("Lua" , "mylib" , set_function )
38
38
39
- def test_function_flush (self , unstable_r ):
40
- unstable_r .function_load ("Lua" , "mylib" , function )
41
- assert unstable_r .fcall ("myfunc" , 0 , "hello" ) == "hello"
42
- assert unstable_r .function_flush ()
39
+ def test_function_flush (self , r ):
40
+ r .function_load ("Lua" , "mylib" , function )
41
+ assert r .fcall ("myfunc" , 0 , "hello" ) == "hello"
42
+ assert r .function_flush ()
43
43
with pytest .raises (ResponseError ):
44
- unstable_r .fcall ("myfunc" , 0 , "hello" )
44
+ r .fcall ("myfunc" , 0 , "hello" )
45
45
with pytest .raises (ResponseError ):
46
- unstable_r .function_flush ("ABC" )
46
+ r .function_flush ("ABC" )
47
47
48
48
@pytest .mark .onlynoncluster
49
- def test_function_list (self , unstable_r ):
50
- unstable_r .function_load ("Lua" , "mylib" , function )
49
+ def test_function_list (self , r ):
50
+ r .function_load ("Lua" , "mylib" , function )
51
51
res = [
52
52
[
53
53
"library_name" ,
@@ -60,13 +60,13 @@ def test_function_list(self, unstable_r):
60
60
[["name" , "myfunc" , "description" , None ]],
61
61
],
62
62
]
63
- assert unstable_r .function_list () == res
64
- assert unstable_r .function_list (library = "*lib" ) == res
65
- assert unstable_r .function_list (withcode = True )[0 ][9 ] == function
63
+ assert r .function_list () == res
64
+ assert r .function_list (library = "*lib" ) == res
65
+ assert r .function_list (withcode = True )[0 ][9 ] == function
66
66
67
67
@pytest .mark .onlycluster
68
- def test_function_list_on_cluster (self , unstable_r ):
69
- unstable_r .function_load ("Lua" , "mylib" , function )
68
+ def test_function_list_on_cluster (self , r ):
69
+ r .function_load ("Lua" , "mylib" , function )
70
70
function_list = [
71
71
[
72
72
"library_name" ,
@@ -79,42 +79,42 @@ def test_function_list_on_cluster(self, unstable_r):
79
79
[["name" , "myfunc" , "description" , None ]],
80
80
],
81
81
]
82
- primaries = unstable_r .get_primaries ()
82
+ primaries = r .get_primaries ()
83
83
res = {}
84
84
for node in primaries :
85
85
res [node .name ] = function_list
86
- assert unstable_r .function_list () == res
87
- assert unstable_r .function_list (library = "*lib" ) == res
86
+ assert r .function_list () == res
87
+ assert r .function_list (library = "*lib" ) == res
88
88
node = primaries [0 ].name
89
- assert unstable_r .function_list (withcode = True )[node ][0 ][9 ] == function
89
+ assert r .function_list (withcode = True )[node ][0 ][9 ] == function
90
90
91
- def test_fcall (self , unstable_r ):
92
- unstable_r .function_load ("Lua" , "mylib" , set_function )
93
- unstable_r .function_load ("Lua" , "mylib2" , get_function )
94
- assert unstable_r .fcall ("set" , 1 , "foo" , "bar" ) == "OK"
95
- assert unstable_r .fcall ("get" , 1 , "foo" ) == "bar"
91
+ def test_fcall (self , r ):
92
+ r .function_load ("Lua" , "mylib" , set_function )
93
+ r .function_load ("Lua" , "mylib2" , get_function )
94
+ assert r .fcall ("set" , 1 , "foo" , "bar" ) == "OK"
95
+ assert r .fcall ("get" , 1 , "foo" ) == "bar"
96
96
with pytest .raises (ResponseError ):
97
- unstable_r .fcall ("myfunc" , 0 , "hello" )
97
+ r .fcall ("myfunc" , 0 , "hello" )
98
98
99
- def test_fcall_ro (self , unstable_r ):
100
- unstable_r .function_load ("Lua" , "mylib" , function )
101
- assert unstable_r .fcall_ro ("myfunc" , 0 , "hello" ) == "hello"
102
- unstable_r .function_load ("Lua" , "mylib2" , set_function )
99
+ def test_fcall_ro (self , r ):
100
+ r .function_load ("Lua" , "mylib" , function )
101
+ assert r .fcall_ro ("myfunc" , 0 , "hello" ) == "hello"
102
+ r .function_load ("Lua" , "mylib2" , set_function )
103
103
with pytest .raises (ResponseError ):
104
- unstable_r .fcall_ro ("set" , 1 , "foo" , "bar" )
104
+ r .fcall_ro ("set" , 1 , "foo" , "bar" )
105
105
106
- def test_function_dump_restore (self , unstable_r ):
107
- unstable_r .function_load ("Lua" , "mylib" , set_function )
108
- payload = unstable_r .function_dump ()
109
- assert unstable_r .fcall ("set" , 1 , "foo" , "bar" ) == "OK"
110
- unstable_r .function_delete ("mylib" )
106
+ def test_function_dump_restore (self , r ):
107
+ r .function_load ("Lua" , "mylib" , set_function )
108
+ payload = r .function_dump ()
109
+ assert r .fcall ("set" , 1 , "foo" , "bar" ) == "OK"
110
+ r .function_delete ("mylib" )
111
111
with pytest .raises (ResponseError ):
112
- unstable_r .fcall ("set" , 1 , "foo" , "bar" )
113
- assert unstable_r .function_restore (payload )
114
- assert unstable_r .fcall ("set" , 1 , "foo" , "bar" ) == "OK"
115
- unstable_r .function_load ("Lua" , "mylib2" , get_function )
116
- assert unstable_r .fcall ("get" , 1 , "foo" ) == "bar"
117
- unstable_r .function_delete ("mylib" )
118
- assert unstable_r .function_restore (payload , "FLUSH" )
112
+ r .fcall ("set" , 1 , "foo" , "bar" )
113
+ assert r .function_restore (payload )
114
+ assert r .fcall ("set" , 1 , "foo" , "bar" ) == "OK"
115
+ r .function_load ("Lua" , "mylib2" , get_function )
116
+ assert r .fcall ("get" , 1 , "foo" ) == "bar"
117
+ r .function_delete ("mylib" )
118
+ assert r .function_restore (payload , "FLUSH" )
119
119
with pytest .raises (ResponseError ):
120
- unstable_r .fcall ("get" , 1 , "foo" )
120
+ r .fcall ("get" , 1 , "foo" )
0 commit comments