mirror of
https://github.com/emqx/neuron.git
synced 2026-10-26 11:56:10 +08:00
feat(ft): remove template ft
This commit is contained in:
-1350
File diff suppressed because it is too large
Load Diff
@@ -219,77 +219,6 @@ def get_plugins():
|
||||
return requests.get(url=config.BASE_URL + "/api/v2/plugin", headers={"Authorization": config.default_jwt})
|
||||
|
||||
|
||||
@gen_check
|
||||
def add_template(name, plugin, groups=[]):
|
||||
return requests.post(url=config.BASE_URL + "/api/v2/template", json={"name": name, "plugin": plugin, "groups": groups}, headers={"Authorization": config.default_jwt})
|
||||
|
||||
|
||||
@gen_check
|
||||
def del_template(name):
|
||||
return requests.delete(url=config.BASE_URL + "/api/v2/template" + f"?name={name}", headers={"Authorization": config.default_jwt})
|
||||
|
||||
|
||||
@gen_check
|
||||
def get_template(name):
|
||||
return requests.get(url=config.BASE_URL + "/api/v2/template", headers={"Authorization": config.default_jwt}, params={"name": name})
|
||||
|
||||
|
||||
@gen_check
|
||||
def get_templates():
|
||||
return requests.get(url=config.BASE_URL + "/api/v2/template", headers={"Authorization": config.default_jwt})
|
||||
|
||||
|
||||
@gen_check
|
||||
def inst_template(name, node):
|
||||
return requests.post(url=config.BASE_URL + "/api/v2/template/inst", json={"name": name, "node": node}, headers={"Authorization": config.default_jwt})
|
||||
|
||||
|
||||
@gen_check
|
||||
def add_template_group(tmpl, group, interval=100):
|
||||
return requests.post(url=config.BASE_URL + '/api/v2/template/group', headers={"Authorization": config.default_jwt}, json={"template": tmpl, "group": group, "interval": interval})
|
||||
|
||||
|
||||
@gen_check
|
||||
def update_template_group(tmpl, group, new_name="", interval=0):
|
||||
if len(new_name) > 0 and interval > 0:
|
||||
return requests.put(url=config.BASE_URL + '/api/v2/template/group', headers={"Authorization": config.default_jwt}, json={"template": tmpl, "group": group, "new_name": new_name, "interval": interval})
|
||||
elif len(new_name) > 0:
|
||||
return requests.put(url=config.BASE_URL + '/api/v2/template/group', headers={"Authorization": config.default_jwt}, json={"template": tmpl, "group": group, "new_name": new_name})
|
||||
elif interval > 0:
|
||||
return requests.put(url=config.BASE_URL + '/api/v2/template/group', headers={"Authorization": config.default_jwt}, json={"template": tmpl, "group": group, "interval": interval})
|
||||
else:
|
||||
assert False
|
||||
|
||||
|
||||
@gen_check
|
||||
def del_template_group(tmpl, group):
|
||||
return requests.delete(url=config.BASE_URL + '/api/v2/template/group', headers={"Authorization": config.default_jwt}, json={"template": tmpl, "group": group})
|
||||
|
||||
|
||||
@gen_check
|
||||
def get_template_groups(tmpl):
|
||||
return requests.get(url=config.BASE_URL + "/api/v2/template/group", headers={"Authorization": config.default_jwt}, params={"name": tmpl})
|
||||
|
||||
|
||||
@gen_check
|
||||
def add_template_tags(tmpl, group, tags):
|
||||
return requests.post(url=config.BASE_URL + '/api/v2/template/tag', headers={"Authorization": config.default_jwt}, json={"template": tmpl, "group": group, "tags": tags})
|
||||
|
||||
|
||||
@gen_check
|
||||
def update_template_tags(tmpl, group, tags):
|
||||
return requests.put(url=config.BASE_URL + '/api/v2/template/tag', headers={"Authorization": config.default_jwt}, json={"template": tmpl, "group": group, "tags": tags})
|
||||
|
||||
|
||||
@gen_check
|
||||
def del_template_tags(tmpl, group, tags):
|
||||
return requests.delete(url=config.BASE_URL + '/api/v2/template/tag', headers={"Authorization": config.default_jwt}, json={"template": tmpl, "group": group, "tags": tags})
|
||||
|
||||
|
||||
def get_template_tags(tmpl, group, name):
|
||||
return requests.get(url=config.BASE_URL + "/api/v2/template/tag", headers={"Authorization": config.default_jwt}, params={"template": tmpl, "group": group, "name": name})
|
||||
|
||||
|
||||
@gen_check
|
||||
def subscribe_group(app, driver, group, params={}):
|
||||
return requests.post(url=config.BASE_URL + "/api/v2/subscribe", headers={"Authorization": config.default_jwt}, json={"app": app, "driver": driver, "group": group, "params": params})
|
||||
|
||||
@@ -12,26 +12,6 @@
|
||||
"timeout": 3000
|
||||
}
|
||||
},
|
||||
"template_config": {
|
||||
"name": "c1 template",
|
||||
"plugin": "c1",
|
||||
"groups": [
|
||||
{
|
||||
"name": "group1",
|
||||
"interval": 2000,
|
||||
"tags": [
|
||||
{
|
||||
"name": "tag1",
|
||||
"type": 4,
|
||||
"address": "1!400001",
|
||||
"attribute": 1,
|
||||
"precison": 1,
|
||||
"decimal": 0
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
"library_c1": "libplugin-c1.so",
|
||||
"library_s1": "libplugin-s1.so",
|
||||
"library_sc1": "libplugin-sc1.so"
|
||||
|
||||
@@ -346,36 +346,8 @@ class TestPlugin:
|
||||
assert 200 == response.status_code
|
||||
assert NEU_ERR_SUCCESS == response.json().get("error")
|
||||
|
||||
@description(given="correct configuration", when="add template", then="success")
|
||||
def test_18_add_template_success(self):
|
||||
test_data = TestPlugin.test_data
|
||||
template_data = test_data['template_config']
|
||||
|
||||
response = api.add_template(
|
||||
name=template_data['name'], plugin=template_data['plugin'], groups=template_data['groups'])
|
||||
assert 200 == response.status_code
|
||||
assert NEU_ERR_SUCCESS == response.json().get("error")
|
||||
|
||||
@description(given="correct configuration", when="del plugin", then="success")
|
||||
def test_19_del_plugin_fail0(self):
|
||||
test_data = TestPlugin.test_data
|
||||
plugin_data = {}
|
||||
plugin_data['plugin'] = 'c1'
|
||||
|
||||
response = api.del_plugin(plugin_name=plugin_data['plugin'])
|
||||
assert 409 == response.status_code
|
||||
assert NEU_ERR_LIBRARY_IN_USE == response.json().get("error")
|
||||
|
||||
@description(given="correct configuration", when="del template", then="success")
|
||||
def test_20_del_template_success(self):
|
||||
test_data = TestPlugin.test_data
|
||||
|
||||
response = api.del_template(name='c1 template')
|
||||
assert 200 == response.status_code
|
||||
assert NEU_ERR_SUCCESS == response.json().get("error")
|
||||
|
||||
@description(given="correct configuration", when="del plugin", then="success")
|
||||
def test_21_del_plugin_sucess(self):
|
||||
def test_18_del_plugin_sucess(self):
|
||||
test_data = TestPlugin.test_data
|
||||
plugin_data = {}
|
||||
plugin_data['plugin'] = 'c1'
|
||||
|
||||
Reference in New Issue
Block a user