@@ -24,9 +24,43 @@ def test_dag_load(env):
2424 ret = con .execute_command (command )
2525 env .assertEqual (ret , [b'OK' ])
2626
27+
2728def test_dag_load_errors (env ):
2829 con = env .getConnection ()
2930
31+ # ERR wrong number of arguments for LOAD
32+ try :
33+ command = "AI.DAGRUN PERSIST 1 no_tensor{1} LOAD 1"
34+
35+ ret = con .execute_command (command )
36+ except Exception as e :
37+ exception = e
38+ env .assertEqual (type (exception ), redis .exceptions .ResponseError )
39+ env .assertEqual ("wrong number of arguments for LOAD in 'AI.DAGRUN' command" ,exception .__str__ ())
40+
41+ # ERR invalid or negative number of arguments for LOAD
42+ try :
43+ command = "AI.DAGRUN LOAD notnumber{{1}} |> AI.TENSORGET 'no_tensor{1}'"
44+
45+ ret = con .execute_command (command )
46+ except Exception as e :
47+ exception = e
48+ env .assertEqual (type (exception ), redis .exceptions .ResponseError )
49+ env .assertEqual ("invalid or negative value found in number of keys to LOAD" ,exception .__str__ ())
50+
51+ con .execute_command ('AI.TENSORSET' , 'a{{1}}' , 'FLOAT' , 2 , 2 , 'VALUES' , 2 , 3 , 2 , 3 )
52+
53+ # ERR number of keys to LOAD does not match the number of given arguments.
54+ try :
55+ command = "AI.DAGRUN LOAD 2 a{{1}}"
56+
57+ ret = con .execute_command (command )
58+ except Exception as e :
59+ exception = e
60+ env .assertEqual (type (exception ), redis .exceptions .ResponseError )
61+ env .assertEqual ("number of keys to LOAD in AI.DAGRUN command does not match the number of "
62+ "given arguments" , exception .__str__ ())
63+
3064 # ERR tensor key is empty
3165 try :
3266 command = "AI.DAGRUN " \
@@ -55,51 +89,91 @@ def test_dag_load_errors(env):
5589 env .assertEqual ("WRONGTYPE Operation against a key holding the wrong kind of value" ,exception .__str__ ())
5690
5791
58- def test_dag_common_errors (env ):
92+ def test_dag_persist_errors (env ):
5993 con = env .getConnection ()
94+ con .execute_command ('AI.TENSORSET' , 'a{{1}}' , 'FLOAT' , 2 , 2 , 'VALUES' , 2 , 3 , 2 , 3 )
6095
61- # ERR unsupported command within DAG
96+ # ERR wrong number of arguments for PERSIST
6297 try :
63- command = "AI.DAGRUN |> " \
64- "AI.DONTEXIST tensor1{{1}} FLOAT 1 2 VALUES 5 10"
98+ command = "AI.DAGRUN LOAD 1 a{{1}} PERSIST 1"
6599
66100 ret = con .execute_command (command )
67101 except Exception as e :
68102 exception = e
69103 env .assertEqual (type (exception ), redis .exceptions .ResponseError )
70- env .assertEqual ("unsupported command within DAG " ,exception .__str__ ())
104+ env .assertEqual ("wrong number of arguments for PERSIST in 'AI.DAGRUN' command " ,exception .__str__ ())
71105
72- # ERR wrong number of arguments for 'AI.DAGRUN' command
106+ # ERR invalid or negative value found in number of keys to PERSIST
73107 try :
74- command = "AI.DAGRUN "
108+ command = "AI.DAGRUN PERSIST notnumber{{1}} |> " \
109+ "AI.TENSORSET tensor1 FLOAT 1 2 VALUES 5 10"
75110
76111 ret = con .execute_command (command )
77112 except Exception as e :
78113 exception = e
79114 env .assertEqual (type (exception ), redis .exceptions .ResponseError )
80- env .assertEqual ("wrong number of arguments for 'AI.DAGRUN' command " ,exception .__str__ ())
115+ env .assertEqual ("invalid or negative value found in number of keys to PERSIST " ,exception .__str__ ())
81116
82- # ERR invalid or negative value found in number of keys to PERSIST
117+ # ERR number of keys to PERSIST does not match the number of given arguments.
118+ try :
119+ command = "AI.DAGRUN PERSIST 2 tensor1{1}"
120+
121+ ret = con .execute_command (command )
122+ except Exception as e :
123+ exception = e
124+ env .assertEqual (type (exception ), redis .exceptions .ResponseError )
125+ env .assertEqual ("number of keys to PERSIST in AI.DAGRUN command does not match the number of "
126+ "given arguments" , exception .__str__ ())
127+
128+
129+ def test_dag_timeout_errors (env ):
130+ con = env .getConnection ()
131+
132+ # ERR no value provided for timeout
83133 try :
84- command = "AI.DAGRUN PERSIST notnumber{{1}} |> " \
134+ command = "AI.DAGRUN PERSIST 1 no_tensor{1} TIMEOUT"
135+
136+ ret = con .execute_command (command )
137+ except Exception as e :
138+ exception = e
139+ env .assertEqual (type (exception ), redis .exceptions .ResponseError )
140+ env .assertEqual ("No value provided for TIMEOUT" ,exception .__str__ ())
141+
142+ # ERR invalid timeout value
143+ try :
144+ command = "AI.DAGRUN TIMEOUT notnumber{{1}} |> " \
85145 "AI.TENSORSET tensor1 FLOAT 1 2 VALUES 5 10"
86146
87147 ret = con .execute_command (command )
88148 except Exception as e :
89149 exception = e
90150 env .assertEqual (type (exception ), redis .exceptions .ResponseError )
91- env .assertEqual ("invalid or negative value found in number of keys to PERSIST " ,exception .__str__ ())
151+ env .assertEqual ("Invalid value for TIMEOUT " ,exception .__str__ ())
92152
93- # ERR invalid or negative value found in number of keys to LOAD
153+
154+ def test_dag_common_errors (env ):
155+ con = env .getConnection ()
156+
157+ # ERR unsupported command within DAG
94158 try :
95- command = "AI.DAGRUN LOAD notnumber{{1}} |> " \
96- "AI.TENSORSET tensor1 FLOAT 1 2 VALUES 5 10"
159+ command = "AI.DAGRUN |> " \
160+ "AI.DONTEXIST tensor1{{1}} FLOAT 1 2 VALUES 5 10"
97161
98162 ret = con .execute_command (command )
99163 except Exception as e :
100164 exception = e
101165 env .assertEqual (type (exception ), redis .exceptions .ResponseError )
102- env .assertEqual ("invalid or negative value found in number of keys to LOAD" ,exception .__str__ ())
166+ env .assertEqual ("unsupported command within DAG" ,exception .__str__ ())
167+
168+ # ERR wrong number of arguments for 'AI.DAGRUN' command
169+ try :
170+ command = "AI.DAGRUN "
171+
172+ ret = con .execute_command (command )
173+ except Exception as e :
174+ exception = e
175+ env .assertEqual (type (exception ), redis .exceptions .ResponseError )
176+ env .assertEqual ("wrong number of arguments for 'AI.DAGRUN' command" ,exception .__str__ ())
103177
104178 # ERR DAG with no ops
105179 command = "AI.TENSORSET volatile_tensor1 FLOAT 1 2 VALUES 5 10"
0 commit comments