@@ -44,19 +44,19 @@ def test_create_datasources(self, mock_del, mock_post, mock_put, mock_get):
44
44
response_mock (mock_get , example_ds .model_dump ())
45
45
46
46
ds = client .datasources .create (example_ds )
47
- def check_ds_created (ds , mock_post ):
47
+ def check_ds_created (ds , mock_post , url ):
48
48
self ._compare_ds (ds , example_ds )
49
49
args , kwargs = mock_post .call_args
50
50
51
51
assert kwargs ['headers' ] == {'Authorization' : 'Bearer ' + API_KEY }
52
52
assert kwargs ['json' ] == example_ds .model_dump ()
53
- assert args [0 ] == 'https://mdb.ai/api/datasources'
53
+ assert args [0 ] == url
54
54
55
- check_ds_created (ds , mock_post )
55
+ check_ds_created (ds , mock_post , 'https://mdb.ai/api/datasources' )
56
56
57
57
# with update
58
58
ds = client .datasources .create (example_ds , update = True )
59
- check_ds_created (ds , mock_put )
59
+ check_ds_created (ds , mock_put , f'https://mdb.ai/api/datasources/ { ds . name } ' )
60
60
61
61
@patch ('requests.get' )
62
62
def test_get_datasource (self , mock_get ):
@@ -132,17 +132,17 @@ def test_create(self, mock_del, mock_post, mock_put, mock_get):
132
132
}
133
133
mind = client .minds .create (** create_params )
134
134
135
- def check_mind_created (mind , mock_post , create_params ):
135
+ def check_mind_created (mind , mock_post , create_params , url ):
136
136
args , kwargs = mock_post .call_args
137
- assert args [0 ].endswith ('/api/projects/mindsdb/minds' )
137
+ assert args [0 ].endswith (url )
138
138
request = kwargs ['json' ]
139
139
for key in ('name' , 'datasources' , 'provider' , 'model_name' ),:
140
140
assert request .get (key ) == create_params .get (key )
141
141
assert create_params .get ('prompt_template' ) == request .get ('parameters' , {}).get ('prompt_template' )
142
142
143
143
self .compare_mind (mind , self .mind_json )
144
144
145
- check_mind_created (mind , mock_post , create_params )
145
+ check_mind_created (mind , mock_post , create_params , '/api/projects/mindsdb/minds' )
146
146
147
147
# -- with replace --
148
148
create_params = {
@@ -156,15 +156,15 @@ def check_mind_created(mind, mock_post, create_params):
156
156
args , _ = mock_del .call_args
157
157
assert args [0 ].endswith (f'/api/projects/mindsdb/minds/{ mind_name } ' )
158
158
159
- check_mind_created (mind , mock_post , create_params )
159
+ check_mind_created (mind , mock_post , create_params , '/api/projects/mindsdb/minds' )
160
160
161
161
# -- with update --
162
162
mock_del .reset_mock ()
163
163
mind = client .minds .create (update = True , ** create_params )
164
164
# is not deleted
165
165
assert not mock_del .called
166
166
167
- check_mind_created (mind , mock_put , create_params )
167
+ check_mind_created (mind , mock_put , create_params , f'/api/projects/mindsdb/minds/ { mind_name } ' )
168
168
169
169
@patch ('requests.get' )
170
170
@patch ('requests.patch' )
0 commit comments