mirror of
https://github.com/emqx/neuron.git
synced 2026-10-17 04:40:42 +08:00
test query nodes by tags
This commit is contained in:
@@ -98,6 +98,9 @@ def get_nodes(type, jwt=config.default_jwt, group=""):
|
||||
else:
|
||||
return requests.get(url=config.BASE_URL + '/api/v2/node?group=' + group, headers={"Authorization": jwt}, params={"type": type})
|
||||
|
||||
def get_nodes_by_tags(type, tags, jwt=config.default_jwt):
|
||||
return requests.get(url=config.BASE_URL + '/api/v2/node', headers={"Authorization": jwt}, params={"type": type, "node": tags})
|
||||
|
||||
|
||||
@gen_check
|
||||
def node_ctl(node, ctl, jwt=config.default_jwt):
|
||||
|
||||
@@ -52,4 +52,24 @@ class TestNodeTag:
|
||||
def test_add_tags_exceeding_limit(self):
|
||||
response = api.add_node_with_tags(node="modbus-tcp-3", plugin=PLUGIN_MODBUS_TCP, tags="tag1,tag2,tag3,tag4,tag5,tag6")
|
||||
assert 400 == response.status_code
|
||||
assert NEU_ERR_NODE_TAGS_TOO_MANY == response.json()['error']
|
||||
assert NEU_ERR_NODE_TAGS_TOO_MANY == response.json()['error']
|
||||
|
||||
@description(given="node with tags", when="query node by tags", then="query success")
|
||||
def test_query_node_by_tags(self):
|
||||
response = api.add_node_with_tags(node="modbus-tcp-4", plugin=PLUGIN_MODBUS_TCP, tags="tagA,tagB")
|
||||
assert 200 == response.status_code
|
||||
assert NEU_ERR_SUCCESS == response.json()['error']
|
||||
|
||||
response = api.get_nodes_by_tags(type=1, tags="tagA")
|
||||
assert 200 == response.status_code
|
||||
assert 1 == len(response.json()['nodes'])
|
||||
assert "modbus-tcp-4" == response.json()['nodes'][0]['name']
|
||||
|
||||
response = api.get_nodes_by_tags(type=1, tags="tagB")
|
||||
assert 200 == response.status_code
|
||||
assert 1 == len(response.json()['nodes'])
|
||||
assert "modbus-tcp-4" == response.json()['nodes'][0]['name']
|
||||
|
||||
response = api.get_nodes_by_tags(type=1, tags="tagC")
|
||||
assert 200 == response.status_code
|
||||
assert 0 == len(response.json()['nodes'])
|
||||
Reference in New Issue
Block a user