Skip to content

Commit 07a8b8b

Browse files
committed
Update tests
1 parent 6296401 commit 07a8b8b

File tree

1 file changed

+39
-19
lines changed

1 file changed

+39
-19
lines changed

tests/test_sdk.py

Lines changed: 39 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -237,11 +237,25 @@ def test_flow(self, mock_post, mock_put, mock_get):
237237
assert call_args[0][0] == 'https://cloud.mindsdb.com/api/status'
238238

239239
# --------- databases -------------
240-
response_mock(mock_post, pd.DataFrame([{'NAME': 'db1','ENGINE': 'postgres'}]))
240+
response_mock(
241+
mock_post,
242+
pd.DataFrame(
243+
[
244+
{
245+
"NAME": "db1",
246+
"ENGINE": "postgres",
247+
"CONNECTION_DATA": {"host": "zoop"},
248+
}
249+
]
250+
),
251+
)
241252

242253
databases = server.list_databases()
243254

244-
check_sql_call(mock_post, "select NAME, ENGINE from information_schema.databases where TYPE='data'")
255+
check_sql_call(
256+
mock_post,
257+
"select NAME, ENGINE, CONNECTION_DATA from information_schema.databases where TYPE='data'",
258+
)
245259

246260
database = databases[0]
247261
str(database)
@@ -465,7 +479,6 @@ def check_project_models(self, project, database, mock_post):
465479
}
466480
)
467481

468-
469482
@patch('requests.Session.post')
470483
def check_project_models_versions(self, project, database, mock_post):
471484
# ----------- model version --------------
@@ -495,7 +508,6 @@ def check_project_models_versions(self, project, database, mock_post):
495508
project.drop_model_version('m1', 1)
496509
check_sql_call(mock_post, f"DROP PREDICTOR m1.`1`")
497510

498-
499511
@patch('requests.Session.post')
500512
def check_database(self, database, mock_post):
501513

@@ -545,7 +557,6 @@ def check_database(self, database, mock_post):
545557
database.drop_table('t3')
546558
check_sql_call(mock_post, f'drop table {database.name}.t3')
547559

548-
549560
@patch('requests.Session.post')
550561
def check_project_jobs(self, project, mock_post):
551562

@@ -1415,7 +1426,6 @@ def test_create(self, mock_get, mock_post):
14151426

14161427
assert new_agent == expected_agent
14171428

1418-
14191429
@patch('requests.Session.get')
14201430
@patch('requests.Session.put')
14211431
# Mock creating new skills.
@@ -1480,7 +1490,6 @@ def test_update(self, mock_get, mock_put, _):
14801490

14811491
assert updated_agent == expected_agent
14821492

1483-
14841493
@patch('requests.Session.post')
14851494
def test_completion(self, mock_post):
14861495
response_mock(mock_post, {
@@ -1693,18 +1702,29 @@ def test_add_database(self, mock_post, mock_put, mock_get):
16931702
'provider': 'mindsdb'
16941703
},
16951704
])
1696-
responses_mock(mock_post, [
1697-
# DB get (POST /sql).
1698-
pd.DataFrame([
1699-
{'NAME': 'existing_db', 'ENGINE': 'postgres'}
1700-
]),
1701-
# DB tables get (POST /sql).
1702-
pd.DataFrame([
1703-
{'name': 'existing_table'}
1704-
]),
1705-
# Skill creation.
1706-
{'name': 'new_skill', 'type': 'sql', 'params': {'database': 'existing_db', 'tables': ['existing_table']}}
1707-
])
1705+
responses_mock(
1706+
mock_post,
1707+
[
1708+
# DB get (POST /sql).
1709+
pd.DataFrame(
1710+
[
1711+
{
1712+
"NAME": "existing_db",
1713+
"ENGINE": "postgres",
1714+
"CONNECTION_DATA": {"host": "boop"},
1715+
}
1716+
]
1717+
),
1718+
# DB tables get (POST /sql).
1719+
pd.DataFrame([{"name": "existing_table"}]),
1720+
# Skill creation.
1721+
{
1722+
"name": "new_skill",
1723+
"type": "sql",
1724+
"params": {"database": "existing_db", "tables": ["existing_table"]},
1725+
},
1726+
],
1727+
)
17081728
responses_mock(mock_put, [
17091729
# Agent update with new skill.
17101730
{

0 commit comments

Comments
 (0)