@@ -36,9 +36,10 @@ def _compare_ds(self, ds1, ds2):
3636 assert ds1 .tables == ds2 .tables
3737
3838 @patch ('requests.get' )
39+ @patch ('requests.put' )
3940 @patch ('requests.post' )
4041 @patch ('requests.delete' )
41- def test_create_datasources (self , mock_del , mock_post , mock_get ):
42+ def test_create_datasources (self , mock_del , mock_post , mock_put , mock_get ):
4243 client = get_client ()
4344 response_mock (mock_get , example_ds .model_dump ())
4445
@@ -53,12 +54,9 @@ def check_ds_created(ds, mock_post):
5354
5455 check_ds_created (ds , mock_post )
5556
56- # with replace
57- ds = client .datasources .create (example_ds , replace = True )
58- args , _ = mock_del .call_args
59- assert args [0 ].endswith (f'/api/datasources/{ example_ds .name } ' )
60-
61- check_ds_created (ds , mock_post )
57+ # with update
58+ ds = client .datasources .create (example_ds , update = True )
59+ check_ds_created (ds , mock_put )
6260
6361 @patch ('requests.get' )
6462 def test_get_datasource (self , mock_get ):
@@ -115,9 +113,10 @@ def compare_mind(self, mind, mind_json):
115113 assert mind .parameters == mind_json ['parameters' ]
116114
117115 @patch ('requests.get' )
116+ @patch ('requests.put' )
118117 @patch ('requests.post' )
119118 @patch ('requests.delete' )
120- def test_create (self , mock_del , mock_post , mock_get ):
119+ def test_create (self , mock_del , mock_post , mock_put , mock_get ):
121120 client = get_client ()
122121
123122 mind_name = 'test_mind'
@@ -145,7 +144,7 @@ def check_mind_created(mind, mock_post, create_params):
145144
146145 check_mind_created (mind , mock_post , create_params )
147146
148- # with replace
147+ # -- with replace --
149148 create_params = {
150149 'name' : mind_name ,
151150 'prompt_template' : prompt_template ,
@@ -159,6 +158,14 @@ def check_mind_created(mind, mock_post, create_params):
159158
160159 check_mind_created (mind , mock_post , create_params )
161160
161+ # -- with update --
162+ mock_del .reset_mock ()
163+ mind = client .minds .create (update = True , ** create_params )
164+ # is not deleted
165+ assert not mock_del .called
166+
167+ check_mind_created (mind , mock_put , create_params )
168+
162169 @patch ('requests.get' )
163170 @patch ('requests.patch' )
164171 def test_update (self , mock_patch , mock_get ):
0 commit comments