diff --git a/grai-client/pyproject.toml b/grai-client/pyproject.toml index 06e2553cf..1fccb2fbf 100644 --- a/grai-client/pyproject.toml +++ b/grai-client/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "grai-client" -version = "0.2.12" +version = "0.2.13" description = "" authors = ["Ian Eaves "] license = "Elastic-2.0" diff --git a/grai-client/src/grai_client/endpoints/v1/get.py b/grai-client/src/grai_client/endpoints/v1/get.py index 2acc254e6..262e0eb21 100644 --- a/grai-client/src/grai_client/endpoints/v1/get.py +++ b/grai-client/src/grai_client/endpoints/v1/get.py @@ -156,6 +156,7 @@ def finalize_edge(client: ClientV1, resp: Dict, options: ClientOptions = ClientO """ nodes = [get(client, "node", resp["source"]), get(client, "node", resp["destination"])] + resp["source"] = nodes[0].spec resp["destination"] = nodes[1].spec return EdgeV1.from_spec(resp) @@ -272,7 +273,7 @@ def get_from_edge_named_id( if num_results == 0: return None elif num_results == 1: - return finalize_edge(client, resp[0]) + return resp[0] else: message = ( f"An edge query for name={grai_type.name}, namespace={grai_type.namespace} in the " diff --git a/grai-client/tests/test_v1.py b/grai-client/tests/test_v1.py index eed94778c..dd3fbaed1 100644 --- a/grai-client/tests/test_v1.py +++ b/grai-client/tests/test_v1.py @@ -3,6 +3,7 @@ import pytest from grai_schemas.v1 import EdgeV1, NodeV1 +from grai_schemas.v1.edge import EdgeNamedID, EdgeUuidID from requests import RequestException from grai_client.endpoints.utilities import is_valid_uuid @@ -190,3 +191,12 @@ def test_edge_hash(client): new_edge = client.post(test_edge) assert hash(new_edge) == hash(test_edge) + + +def test_get_edge_by_named_id(client): + test_edge, test_nodes = mock_v1_edge_and_nodes() + objs = client.post([*test_nodes, test_edge]) + + identifier = EdgeNamedID(name=test_edge.spec.name, namespace=test_edge.spec.namespace) + result = client.get(identifier) + assert hash(result) == hash(test_edge), "Edge should be queryable by named id"