Skip to content

Commit

Permalink
Bug/client named edge (#398)
Browse files Browse the repository at this point in the history
* okay'

* commit message

* bugix

* oldchange

* oldchange
  • Loading branch information
ieaves authored Jun 1, 2023
1 parent 20a6f67 commit 6b3443a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion grai-client/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "grai-client"
version = "0.2.12"
version = "0.2.13"
description = ""
authors = ["Ian Eaves <[email protected]>"]
license = "Elastic-2.0"
Expand Down
3 changes: 2 additions & 1 deletion grai-client/src/grai_client/endpoints/v1/get.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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 "
Expand Down
10 changes: 10 additions & 0 deletions grai-client/tests/test_v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"

0 comments on commit 6b3443a

Please sign in to comment.