mirror of
https://github.com/emqx/neuron.git
synced 2026-10-26 20:09:48 +08:00
Merge pull request #2652 from hxy7yx/main-2
chore:update key from nodes to apps
This commit is contained in:
@@ -799,13 +799,13 @@ int neu_json_encode_apps_req(void *obj_json, void *param)
|
||||
return -1;
|
||||
}
|
||||
|
||||
json_t *nodes_json = json_array();
|
||||
if (NULL == nodes_json ||
|
||||
0 != json_object_set_new(root, "nodes", nodes_json)) {
|
||||
json_t *apps_json = json_array();
|
||||
if (NULL == apps_json ||
|
||||
0 != json_object_set_new(root, "apps", apps_json)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return neu_json_encode_app_array(nodes_json, param);
|
||||
return neu_json_encode_app_array(apps_json, param);
|
||||
}
|
||||
|
||||
int neu_json_decode_apps_req(char *buf, neu_json_apps_req_t **result)
|
||||
@@ -822,14 +822,14 @@ int neu_json_decode_apps_req(char *buf, neu_json_apps_req_t **result)
|
||||
return -1;
|
||||
}
|
||||
|
||||
json_t *nodes_json = json_object_get(json_obj, "nodes");
|
||||
if (!json_is_array(nodes_json)) {
|
||||
json_t *apps_json = json_object_get(json_obj, "apps");
|
||||
if (!json_is_array(apps_json)) {
|
||||
neu_json_decode_free(json_obj);
|
||||
free(req);
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = neu_json_decode_app_array_json(nodes_json, req);
|
||||
ret = neu_json_decode_app_array_json(apps_json, req);
|
||||
if (0 == ret) {
|
||||
*result = req;
|
||||
} else {
|
||||
|
||||
@@ -31,10 +31,10 @@ class TestAppsExportImport:
|
||||
assert 'attachment' in response.headers.get('Content-Disposition', '')
|
||||
|
||||
data = response.json()
|
||||
assert 'nodes' in data
|
||||
assert 'apps' in data
|
||||
|
||||
app_data = None
|
||||
for node in data['nodes']:
|
||||
for node in data['apps']:
|
||||
if node['name'] == app:
|
||||
app_data = node
|
||||
break
|
||||
@@ -127,8 +127,8 @@ class TestAppsExportImport:
|
||||
response = api.get_apps(names=[app])
|
||||
assert 200 == response.status_code
|
||||
data = response.json()
|
||||
assert len(data['nodes']) == 1
|
||||
assert 'neuron_overwrite_test' in str(data['nodes'][0].get('params', ''))
|
||||
assert len(data['apps']) == 1
|
||||
assert 'neuron_overwrite_test' in str(data['apps'][0].get('params', ''))
|
||||
|
||||
finally:
|
||||
api.del_node(app)
|
||||
@@ -190,16 +190,16 @@ class TestAppsExportImport:
|
||||
assert 200 == response.status_code
|
||||
exported_data = response.json()
|
||||
|
||||
assert 'nodes' in exported_data
|
||||
assert len(exported_data['nodes']) == 1
|
||||
app_config = exported_data['nodes'][0]
|
||||
assert 'apps' in exported_data
|
||||
assert len(exported_data['apps']) == 1
|
||||
app_config = exported_data['apps'][0]
|
||||
assert app_config['name'] == app
|
||||
|
||||
api.del_node(app)
|
||||
response = api.get_nodes_state(app)
|
||||
assert response.json()['error'] == error.NEU_ERR_NODE_NOT_EXIST
|
||||
|
||||
response = api.put_apps(exported_data['nodes'])
|
||||
response = api.put_apps(exported_data['apps'])
|
||||
assert 200 == response.status_code
|
||||
assert error.NEU_ERR_SUCCESS == response.json()['error']
|
||||
|
||||
|
||||
@@ -315,7 +315,7 @@ def get_apps(names=None, jwt=config.default_jwt):
|
||||
|
||||
|
||||
def put_apps(apps, jwt=config.default_jwt):
|
||||
return requests.put(url=config.BASE_URL + '/api/v2/global/apps', headers={"Authorization": jwt}, json={"nodes": apps})
|
||||
return requests.put(url=config.BASE_URL + '/api/v2/global/apps', headers={"Authorization": jwt}, json={"apps": apps})
|
||||
|
||||
|
||||
def get_status():
|
||||
|
||||
Reference in New Issue
Block a user