99
1010from minds .datasources .examples import example_ds
1111
12- from minds .exceptions import ObjectNotFound
12+ from minds .exceptions import ObjectNotFound , MindNameInvalid
1313
1414
1515def get_client ():
@@ -37,7 +37,8 @@ def test_datasources():
3737
3838 # create
3939 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 )
4142 assert ds .name == example_ds .name
4243
4344 # get
@@ -57,6 +58,7 @@ def test_minds():
5758 ds_name = 'test_datasource_'
5859 ds_name2 = 'test_datasource2_'
5960 mind_name = 'int_test_mind_'
61+ invalid_mind_name = 'mind-123'
6062 mind_name2 = 'int_test_mind2_'
6163 prompt1 = 'answer in german'
6264 prompt2 = 'answer in spanish'
@@ -79,6 +81,13 @@ def test_minds():
7981 ds2_cfg .tables = ['home_rentals' ]
8082
8183 # create
84+ with pytest .raises (MindNameInvalid ):
85+ mind = client .minds .create (
86+ invalid_mind_name ,
87+ datasources = [ds ],
88+ provider = 'openai'
89+ )
90+
8291 mind = client .minds .create (
8392 mind_name ,
8493 datasources = [ds ],
@@ -90,11 +99,20 @@ def test_minds():
9099 datasources = [ds .name , ds2_cfg ],
91100 prompt_template = prompt1
92101 )
102+ mind = client .minds .create (
103+ mind_name ,
104+ update = True ,
105+ datasources = [ds .name , ds2_cfg ],
106+ prompt_template = prompt1
107+ )
93108
94109 # get
95110 mind = client .minds .get (mind_name )
96111 assert len (mind .datasources ) == 2
97112 assert mind .prompt_template == prompt1
113+
114+ with pytest .raises (MindNameInvalid ):
115+ client .minds .get (invalid_mind_name )
98116
99117 # list
100118 mind_list = client .minds .list ()
@@ -106,6 +124,14 @@ def test_minds():
106124 datasources = [ds .name ],
107125 prompt_template = prompt2
108126 )
127+
128+ with pytest .raises (MindNameInvalid ):
129+ mind .update (
130+ name = invalid_mind_name ,
131+ datasources = [ds .name ],
132+ prompt_template = prompt2
133+ )
134+
109135 with pytest .raises (ObjectNotFound ):
110136 # this name not exists
111137 client .minds .get (mind_name )
@@ -153,3 +179,6 @@ def test_minds():
153179 client .minds .drop (mind_name2 )
154180 client .datasources .drop (ds .name )
155181 client .datasources .drop (ds2_cfg .name )
182+
183+ with pytest .raises (MindNameInvalid ):
184+ client .minds .drop (invalid_mind_name )
0 commit comments