test_read_outgoing.py 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  1. import pytest
  2. @pytest.mark.usefixtures("state")
  3. def test_read_outgoing_node_none(state):
  4. b = state.create_node()
  5. assert b is not None
  6. l = state.read_outgoing(b)
  7. assert l is not None
  8. assert set(l) == set([])
  9. @pytest.mark.usefixtures("state")
  10. def test_read_outgoing_node_one(state):
  11. a = state.create_node()
  12. b = state.create_node()
  13. c = state.create_edge(a, b)
  14. assert a is not None
  15. assert b is not None
  16. assert c is not None
  17. l = state.read_outgoing(a)
  18. assert l is not None
  19. assert set(l) == set([c])
  20. l = state.read_outgoing(b)
  21. assert l is not None
  22. assert set(l) == set([])
  23. @pytest.mark.usefixtures("state")
  24. def test_read_outgoing_node_multi(state):
  25. a = state.create_node()
  26. b = state.create_node()
  27. c = state.create_edge(a, b)
  28. d = state.create_edge(a, b)
  29. e = state.create_edge(a, b)
  30. assert a is not None
  31. assert b is not None
  32. assert c is not None
  33. assert d is not None
  34. assert e is not None
  35. l = state.read_outgoing(a)
  36. assert l is not None
  37. assert set(l) == set([c, d, e])
  38. l = state.read_outgoing(b)
  39. assert l is not None
  40. assert set(l) == set([])
  41. @pytest.mark.usefixtures("state")
  42. def test_read_outgoing_node_multi_others_unaffected(state):
  43. a = state.create_node()
  44. b = state.create_node()
  45. c = state.create_edge(a, b)
  46. d = state.create_edge(a, b)
  47. e = state.create_edge(a, b)
  48. assert a is not None
  49. assert b is not None
  50. assert c is not None
  51. assert d is not None
  52. assert e is not None
  53. f = state.create_node()
  54. assert f is not None
  55. l = state.read_outgoing(a)
  56. assert l is not None
  57. assert set(l) == set([c, d, e])
  58. l = state.read_outgoing(b)
  59. assert l is not None
  60. assert set(l) == set([])
  61. l = state.read_outgoing(f)
  62. assert l is not None
  63. assert set(l) == set([])
  64. @pytest.mark.usefixtures("state")
  65. def test_read_outgoing_edge_none(state):
  66. a = state.create_node()
  67. b = state.create_node()
  68. c = state.create_edge(a, b)
  69. assert a is not None
  70. assert b is not None
  71. assert c is not None
  72. l = state.read_outgoing(c)
  73. assert l is not None
  74. assert set(l) == set([])
  75. @pytest.mark.usefixtures("state")
  76. def test_read_outgoing_edge_one(state):
  77. a = state.create_node()
  78. b = state.create_node()
  79. c = state.create_edge(a, b)
  80. d = state.create_edge(c, a)
  81. assert a is not None
  82. assert b is not None
  83. assert c is not None
  84. assert d is not None
  85. l = state.read_outgoing(c)
  86. assert l is not None
  87. assert set(l) == set([d])
  88. l = state.read_outgoing(d)
  89. assert l is not None
  90. assert set(l) == set([])
  91. @pytest.mark.usefixtures("state")
  92. def test_read_outgoing_edge_multi(state):
  93. a = state.create_node()
  94. b = state.create_node()
  95. c = state.create_edge(a, b)
  96. d = state.create_edge(c, a)
  97. e = state.create_edge(c, b)
  98. f = state.create_edge(c, d)
  99. assert a is not None
  100. assert b is not None
  101. assert c is not None
  102. assert d is not None
  103. assert e is not None
  104. assert f is not None
  105. l = state.read_outgoing(c)
  106. assert l is not None
  107. assert set(l) == set([d, e, f])
  108. l = state.read_outgoing(d)
  109. assert l is not None
  110. assert set(l) == set([])
  111. l = state.read_outgoing(e)
  112. assert l is not None
  113. assert set(l) == set([])
  114. l = state.read_outgoing(f)
  115. assert l is not None
  116. assert set(l) == set([])
  117. @pytest.mark.usefixtures("state")
  118. def test_read_outgoing_nodevalue_none(state):
  119. b = state.create_nodevalue(1)
  120. assert b is not None
  121. l = state.read_outgoing(b)
  122. assert l is not None
  123. assert set(l) == set([])
  124. @pytest.mark.usefixtures("state")
  125. def test_read_outgoing_nodevalue_one(state):
  126. a = state.create_nodevalue(1)
  127. b = state.create_node()
  128. c = state.create_edge(a, b)
  129. assert a is not None
  130. assert b is not None
  131. assert c is not None
  132. l = state.read_outgoing(a)
  133. assert l is not None
  134. assert set(l) == set([c])
  135. l = state.read_outgoing(b)
  136. assert l is not None
  137. assert set(l) == set([])
  138. @pytest.mark.usefixtures("state")
  139. def test_read_outgoing_nodevalue_multi(state):
  140. a = state.create_nodevalue(1)
  141. b = state.create_node()
  142. c = state.create_edge(a, b)
  143. d = state.create_edge(a, b)
  144. e = state.create_edge(a, b)
  145. assert a is not None
  146. assert b is not None
  147. assert c is not None
  148. assert d is not None
  149. assert e is not None
  150. l = state.read_outgoing(a)
  151. assert l is not None
  152. assert set(l) == set([c, d, e])
  153. l = state.read_outgoing(b)
  154. assert l is not None
  155. assert set(l) == set([])
  156. @pytest.mark.usefixtures("state")
  157. def test_read_outgoing_nodevalue_multi_others_unaffected(state):
  158. a = state.create_nodevalue(1)
  159. b = state.create_node()
  160. c = state.create_edge(a, b)
  161. d = state.create_edge(a, b)
  162. e = state.create_edge(a, b)
  163. assert a is not None
  164. assert b is not None
  165. assert c is not None
  166. assert d is not None
  167. assert e is not None
  168. f = state.create_nodevalue(1)
  169. assert f is not None
  170. l = state.read_outgoing(a)
  171. assert l is not None
  172. assert set(l) == set([c, d, e])
  173. l = state.read_outgoing(b)
  174. assert l is not None
  175. assert set(l) == set([])
  176. l = state.read_outgoing(f)
  177. assert l is not None
  178. assert set(l) == set([])
  179. @pytest.mark.usefixtures("state")
  180. def test_read_outgoing_node_deleted(state):
  181. b = state.create_node()
  182. assert b is not None
  183. n = state.delete_node(b)
  184. assert n is None
  185. l = state.read_outgoing(b)
  186. assert l is None
  187. @pytest.mark.usefixtures("state")
  188. def test_read_outgoing_nodevalue_deleted(state):
  189. b = state.create_nodevalue(1)
  190. assert b is not None
  191. n = state.delete_node(b)
  192. assert n is None
  193. l = state.read_outgoing(b)
  194. assert l is None
  195. @pytest.mark.usefixtures("state")
  196. def test_read_outgoing_edge_deleted(state):
  197. a = state.create_node()
  198. b = state.create_node()
  199. c = state.create_edge(a, b)
  200. assert a is not None
  201. assert b is not None
  202. assert c is not None
  203. n = state.delete_edge(c)
  204. assert n is None
  205. l = state.read_outgoing(c)
  206. assert l is None