mirror of
https://github.com/ipnet-mesh/meshcore-hub.git
synced 2026-03-28 17:42:56 +01:00
Add tests to verify Node API returns tags
- Add test_get_node_with_tags to verify GET /nodes/{pk} includes tags
- Add test_list_nodes_includes_tags to verify GET /nodes includes tags
- Update existing tests to assert tags field is present
The Node API was already correctly returning tags via the
lazy="selectin" relationship loading strategy. These tests
document and verify that behavior.
This commit is contained in:
@@ -21,6 +21,19 @@ class TestListNodes:
|
||||
assert data["total"] == 1
|
||||
assert data["items"][0]["public_key"] == sample_node.public_key
|
||||
assert data["items"][0]["name"] == sample_node.name
|
||||
assert "tags" in data["items"][0]
|
||||
|
||||
def test_list_nodes_includes_tags(
|
||||
self, client_no_auth, sample_node, sample_node_tag
|
||||
):
|
||||
"""Test listing nodes includes their tags."""
|
||||
response = client_no_auth.get("/api/v1/nodes")
|
||||
assert response.status_code == 200
|
||||
data = response.json()
|
||||
assert len(data["items"]) == 1
|
||||
assert len(data["items"][0]["tags"]) == 1
|
||||
assert data["items"][0]["tags"][0]["key"] == sample_node_tag.key
|
||||
assert data["items"][0]["tags"][0]["value"] == sample_node_tag.value
|
||||
|
||||
def test_list_nodes_pagination(self, client_no_auth, sample_node):
|
||||
"""Test node list pagination parameters."""
|
||||
@@ -54,6 +67,19 @@ class TestGetNode:
|
||||
data = response.json()
|
||||
assert data["public_key"] == sample_node.public_key
|
||||
assert data["name"] == sample_node.name
|
||||
assert "tags" in data
|
||||
assert data["tags"] == []
|
||||
|
||||
def test_get_node_with_tags(self, client_no_auth, sample_node, sample_node_tag):
|
||||
"""Test getting a node includes its tags."""
|
||||
response = client_no_auth.get(f"/api/v1/nodes/{sample_node.public_key}")
|
||||
assert response.status_code == 200
|
||||
data = response.json()
|
||||
assert data["public_key"] == sample_node.public_key
|
||||
assert "tags" in data
|
||||
assert len(data["tags"]) == 1
|
||||
assert data["tags"][0]["key"] == sample_node_tag.key
|
||||
assert data["tags"][0]["value"] == sample_node_tag.value
|
||||
|
||||
def test_get_node_not_found(self, client_no_auth):
|
||||
"""Test getting a non-existent node."""
|
||||
|
||||
Reference in New Issue
Block a user