Implemented State

This commit is contained in:
Andrei Bondarenko 2021-07-13 03:39:48 +02:00
parent e2c27b427b
commit 046266bfa4
28 changed files with 3517 additions and 26 deletions

View file

@ -0,0 +1,136 @@
import pytest
@pytest.mark.usefixtures("state")
def test_read_edge_node(state):
b = state.create_node()
assert b is not None
s, t = state.read_edge(b)
assert s is None
assert t is None
@pytest.mark.usefixtures("state")
def test_read_edge_no_exists(state):
s, t = state.read_edge(-1)
assert s is None
assert t is None
@pytest.mark.usefixtures("state")
def test_read_edge_nodevalue(state):
b = state.create_nodevalue(1)
assert b is not None
s, t = state.read_edge(b)
assert s is None
assert t is None
@pytest.mark.usefixtures("state")
def test_read_edge_normal(state):
a = state.create_node()
b = state.create_node()
c = state.create_edge(a, b)
assert a is not None
assert b is not None
assert c is not None
s, t = state.read_edge(c)
assert s == a
assert t == b
@pytest.mark.usefixtures("state")
def test_read_edge_edge_to_edge(state):
a = state.create_node()
b = state.create_node()
c = state.create_edge(a, b)
d = state.create_edge(a, b)
e = state.create_edge(c, d)
assert a is not None
assert b is not None
assert c is not None
assert d is not None
assert e is not None
s, t = state.read_edge(c)
assert s == a
assert t == b
s, t = state.read_edge(d)
assert s == a
assert t == b
s, t = state.read_edge(e)
assert s == c
assert t == d
@pytest.mark.usefixtures("state")
def test_read_edge_edge_to_node(state):
a = state.create_node()
b = state.create_node()
c = state.create_edge(a, b)
d = state.create_edge(c, b)
assert a is not None
assert b is not None
assert c is not None
assert d is not None
s, t = state.read_edge(c)
assert s == a
assert t == b
s, t = state.read_edge(d)
assert s == c
assert t == b
@pytest.mark.usefixtures("state")
def test_read_edge_node_to_edge(state):
a = state.create_node()
b = state.create_node()
c = state.create_edge(a, b)
d = state.create_edge(b, c)
assert a is not None
assert b is not None
assert c is not None
assert d is not None
s, t = state.read_edge(c)
assert s == a
assert t == b
s, t = state.read_edge(d)
assert s == b
assert t == c
@pytest.mark.usefixtures("state")
def test_read_edge_node_to_nodevalue(state):
a = state.create_node()
b = state.create_nodevalue(1)
c = state.create_edge(a, b)
assert a is not None
assert b is not None
assert c is not None
s, t = state.read_edge(c)
assert s == a
assert t == b
@pytest.mark.usefixtures("state")
def test_read_edge_nodevalue_to_nodevalue(state):
a = state.create_nodevalue(1)
b = state.create_nodevalue(1)
c = state.create_edge(a, b)
assert a is not None
assert b is not None
assert c is not None
s, t = state.read_edge(c)
assert s == a
assert t == b