Skip to content

Commit

Permalink
test: fix data source api unittest
Browse files Browse the repository at this point in the history
  • Loading branch information
narasux committed Oct 16, 2023
1 parent 3e676ce commit 2f16025
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/bk-user/tests/apis/web/data_source/test_data_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,21 +217,23 @@ def test_list_other_tenant_data_source(self, api_client, random_tenant, data_sou

class TestDataSourceUpdateApi:
def test_update_local_data_source(self, api_client, data_source, local_ds_plugin_config):
new_data_source_name = generate_random_string()
local_ds_plugin_config["enable_account_password_login"] = False
resp = api_client.put(
reverse("data_source.retrieve_update", kwargs={"id": data_source.id}),
data={"plugin_config": local_ds_plugin_config},
data={"name": new_data_source_name, "plugin_config": local_ds_plugin_config},
)
assert resp.status_code == status.HTTP_204_NO_CONTENT

resp = api_client.get(reverse("data_source.retrieve_update", kwargs={"id": data_source.id}))
assert resp.data["name"] == new_data_source_name
assert resp.data["plugin_config"]["enable_account_password_login"] is False

def test_update_with_invalid_plugin_config(self, api_client, data_source, local_ds_plugin_config):
local_ds_plugin_config.pop("enable_account_password_login")
resp = api_client.put(
reverse("data_source.retrieve_update", kwargs={"id": data_source.id}),
data={"plugin_config": local_ds_plugin_config},
data={"name": generate_random_string(), "plugin_config": local_ds_plugin_config},
)
assert resp.status_code == status.HTTP_400_BAD_REQUEST
assert "插件配置不合法:enable_account_password_login: Field required" in resp.data["message"]
Expand Down

0 comments on commit 2f16025

Please sign in to comment.