test query nodes by tags

This commit is contained in:
fengzero
2026-01-26 03:30:55 +00:00
parent de03827d6b
commit a6fdcb545f
2 changed files with 24 additions and 1 deletions
+3
View File
@@ -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):
+21 -1
View File
@@ -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'])