Skip to content

Commit

Permalink
test: more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
eri24816 committed Mar 23, 2024
1 parent 028ab4f commit f86f749
Showing 1 changed file with 33 additions and 4 deletions.
37 changes: 33 additions & 4 deletions backend/test/test_a.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@

from grapycal.core.workspace import Workspace
from grapycal.stores import main_store
import pytest

def test_node():
def setup_workspace():
workspace = Workspace(port=8766, host="localhost", path="workspace.grapycal", workspace_id=0)
workspace.run(False)

workspace.run(run_runner=False)

def test_edge_creation():
setup_workspace()
from grapycal_builtin.interaction.execNode import ExecNode
n1 = main_store.main_editor.create_node(ExecNode)
n2 = main_store.main_editor.create_node(ExecNode)
Expand All @@ -16,4 +19,30 @@ def test_node():
assert e.tail.get() == p1
assert e.head.get() == p2


def test_max_edges():
setup_workspace()
from grapycal_builtin.interaction.execNode import ExecNode
n1 = main_store.main_editor.create_node(ExecNode)
n2 = main_store.main_editor.create_node(ExecNode)
p1 = n1.add_out_port('out', max_edges=2)
p2 = n2.add_in_port('in')

e1 = main_store.main_editor.create_edge(p1, p2)
e2 = main_store.main_editor.create_edge(p1, p2)

with pytest.raises(Exception):
e3 = main_store.main_editor.create_edge(p1, p2)

def test_edge_deletion():
setup_workspace()
from grapycal_builtin.interaction.execNode import ExecNode
n1 = main_store.main_editor.create_node(ExecNode)
n2 = main_store.main_editor.create_node(ExecNode)
p1 = n1.add_out_port('out')
p2 = n2.add_in_port('in')
e = main_store.main_editor.create_edge(p1, p2)

main_store.main_editor._delete([e.get_id()])

assert p1.edges == []
assert p2.edges == []

0 comments on commit f86f749

Please sign in to comment.