9
9
10
10
from minds .datasources .examples import example_ds
11
11
12
- from minds .exceptions import ObjectNotFound
12
+ from minds .exceptions import ObjectNotFound , MindNameInvalid
13
13
14
14
15
15
def get_client ():
@@ -37,7 +37,8 @@ def test_datasources():
37
37
38
38
# create
39
39
ds = client .datasources .create (example_ds )
40
- ds = client .datasources .create (example_ds , replace = True )
40
+ assert ds .name == example_ds .name
41
+ ds = client .datasources .create (example_ds , update = True )
41
42
assert ds .name == example_ds .name
42
43
43
44
# get
@@ -57,6 +58,7 @@ def test_minds():
57
58
ds_name = 'test_datasource_'
58
59
ds_name2 = 'test_datasource2_'
59
60
mind_name = 'int_test_mind_'
61
+ invalid_mind_name = 'mind-123'
60
62
mind_name2 = 'int_test_mind2_'
61
63
prompt1 = 'answer in german'
62
64
prompt2 = 'answer in spanish'
@@ -79,6 +81,13 @@ def test_minds():
79
81
ds2_cfg .tables = ['home_rentals' ]
80
82
81
83
# create
84
+ with pytest .raises (MindNameInvalid ):
85
+ mind = client .minds .create (
86
+ invalid_mind_name ,
87
+ datasources = [ds ],
88
+ provider = 'openai'
89
+ )
90
+
82
91
mind = client .minds .create (
83
92
mind_name ,
84
93
datasources = [ds ],
@@ -90,11 +99,20 @@ def test_minds():
90
99
datasources = [ds .name , ds2_cfg ],
91
100
prompt_template = prompt1
92
101
)
102
+ mind = client .minds .create (
103
+ mind_name ,
104
+ update = True ,
105
+ datasources = [ds .name , ds2_cfg ],
106
+ prompt_template = prompt1
107
+ )
93
108
94
109
# get
95
110
mind = client .minds .get (mind_name )
96
111
assert len (mind .datasources ) == 2
97
112
assert mind .prompt_template == prompt1
113
+
114
+ with pytest .raises (MindNameInvalid ):
115
+ client .minds .get (invalid_mind_name )
98
116
99
117
# list
100
118
mind_list = client .minds .list ()
@@ -106,6 +124,14 @@ def test_minds():
106
124
datasources = [ds .name ],
107
125
prompt_template = prompt2
108
126
)
127
+
128
+ with pytest .raises (MindNameInvalid ):
129
+ mind .update (
130
+ name = invalid_mind_name ,
131
+ datasources = [ds .name ],
132
+ prompt_template = prompt2
133
+ )
134
+
109
135
with pytest .raises (ObjectNotFound ):
110
136
# this name not exists
111
137
client .minds .get (mind_name )
@@ -153,3 +179,6 @@ def test_minds():
153
179
client .minds .drop (mind_name2 )
154
180
client .datasources .drop (ds .name )
155
181
client .datasources .drop (ds2_cfg .name )
182
+
183
+ with pytest .raises (MindNameInvalid ):
184
+ client .minds .drop (invalid_mind_name )
0 commit comments