Skip to content

Commit

Permalink
Add load node test
Browse files Browse the repository at this point in the history
  • Loading branch information
katarinasupe committed Jan 26, 2022
1 parent dd8a073 commit beb7519
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions tests/ogm/load_node_test.py
@@ -0,0 +1,22 @@
from gqlalchemy import Node, Field, Memgraph


memgraph = Memgraph()

class User(Node):
name: str = Field(index=True, exists=True, unique=True, db=memgraph)

class Streamer(Node, labels={"User", "Stream"}):
name: str = Field(index=True, unique=True, db=memgraph, label="User")
id: str = Field(index=True, unique=True, db=memgraph)
followers: int = Field()
totalViewCount: int = Field()

def test_load_node():
streamer = Streamer(name="Mislav", id="7", followers=777, totalViewCount=7777).save(memgraph)
loaded_streamer = memgraph.load_node(Node(id="7", _label="Stream"))
assert loaded_streamer.name == "Mislav"
assert loaded_streamer.id == "7"
assert loaded_streamer.followers == 777
assert loaded_streamer.totalViewCount == 7777
assert loaded_streamer._labels == {"Streamer", "User"}

0 comments on commit beb7519

Please sign in to comment.