@@ -24,9 +24,43 @@ def test_dag_load(env):
24
24
ret = con .execute_command (command )
25
25
env .assertEqual (ret , [b'OK' ])
26
26
27
+
27
28
def test_dag_load_errors (env ):
28
29
con = env .getConnection ()
29
30
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
+
30
64
# ERR tensor key is empty
31
65
try :
32
66
command = "AI.DAGRUN " \
@@ -55,51 +89,91 @@ def test_dag_load_errors(env):
55
89
env .assertEqual ("WRONGTYPE Operation against a key holding the wrong kind of value" ,exception .__str__ ())
56
90
57
91
58
- def test_dag_common_errors (env ):
92
+ def test_dag_persist_errors (env ):
59
93
con = env .getConnection ()
94
+ con .execute_command ('AI.TENSORSET' , 'a{{1}}' , 'FLOAT' , 2 , 2 , 'VALUES' , 2 , 3 , 2 , 3 )
60
95
61
- # ERR unsupported command within DAG
96
+ # ERR wrong number of arguments for PERSIST
62
97
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"
65
99
66
100
ret = con .execute_command (command )
67
101
except Exception as e :
68
102
exception = e
69
103
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__ ())
71
105
72
- # ERR wrong number of arguments for 'AI.DAGRUN' command
106
+ # ERR invalid or negative value found in number of keys to PERSIST
73
107
try :
74
- command = "AI.DAGRUN "
108
+ command = "AI.DAGRUN PERSIST notnumber{{1}} |> " \
109
+ "AI.TENSORSET tensor1 FLOAT 1 2 VALUES 5 10"
75
110
76
111
ret = con .execute_command (command )
77
112
except Exception as e :
78
113
exception = e
79
114
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__ ())
81
116
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
83
133
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}} |> " \
85
145
"AI.TENSORSET tensor1 FLOAT 1 2 VALUES 5 10"
86
146
87
147
ret = con .execute_command (command )
88
148
except Exception as e :
89
149
exception = e
90
150
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__ ())
92
152
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
94
158
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"
97
161
98
162
ret = con .execute_command (command )
99
163
except Exception as e :
100
164
exception = e
101
165
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__ ())
103
177
104
178
# ERR DAG with no ops
105
179
command = "AI.TENSORSET volatile_tensor1 FLOAT 1 2 VALUES 5 10"
0 commit comments