test_read_dict_edge.py 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. import pytest
  2. @pytest.mark.usefixtures("state")
  3. def test_read_dict_edge_no_exists(state):
  4. assert state.read_dict_edge(-1, "abc") is None
  5. @pytest.mark.usefixtures("state")
  6. def test_read_dict_edge_not_found_node(state):
  7. a = state.create_node()
  8. assert a is not None
  9. # Passing data is not enforced, as the data will be interpreted if necessary
  10. assert state.read_dict_edge(a, "abc") is None
  11. @pytest.mark.usefixtures("state")
  12. def test_read_dict_edge_not_found_nodevalue(state):
  13. a = state.create_nodevalue(1)
  14. assert a is not None
  15. # Passing data is not enforced, as the data will be interpreted if necessary
  16. assert state.read_dict_edge(a, "abc") is None
  17. @pytest.mark.usefixtures("state")
  18. def test_read_dict_edge_not_found_edge(state):
  19. a = state.create_node()
  20. b = state.create_node()
  21. c = state.create_edge(a, b)
  22. assert a is not None
  23. assert b is not None
  24. assert c is not None
  25. # Passing data is not enforced, as the data will be interpreted if necessary
  26. assert state.read_dict_edge(c, "abc") is None
  27. @pytest.mark.usefixtures("state")
  28. def test_read_dict_edge_no_primitive(state):
  29. a = state.create_node()
  30. assert a is not None
  31. # Passing data is not enforced, as the data will be interpreted if necessary
  32. assert state.read_dict_edge(a, a) is None
  33. @pytest.mark.usefixtures("state")
  34. def test_read_dict_edge_node_simple(state):
  35. a = state.create_node()
  36. b = state.create_node()
  37. c = state.create_nodevalue("f")
  38. d = state.create_edge(a, b)
  39. e = state.create_edge(d, c)
  40. assert a is not None
  41. assert b is not None
  42. assert c is not None
  43. assert d is not None
  44. assert e is not None
  45. l = state.read_dict_edge(a, "f")
  46. assert l == d
  47. @pytest.mark.usefixtures("state")
  48. def test_read_dict_edge_node_multi(state):
  49. a = state.create_node()
  50. b = state.create_node()
  51. c = state.create_nodevalue("f")
  52. d = state.create_edge(a, b)
  53. e = state.create_edge(d, c)
  54. assert a is not None
  55. assert b is not None
  56. assert c is not None
  57. assert d is not None
  58. assert e is not None
  59. g = state.create_node()
  60. h = state.create_nodevalue("k")
  61. i = state.create_edge(a, g)
  62. j = state.create_edge(i, h)
  63. assert g is not None
  64. assert h is not None
  65. assert i is not None
  66. assert j is not None
  67. l = state.read_dict_edge(a, "f")
  68. assert l == d
  69. l = state.read_dict_edge(a, "k")
  70. assert l == i
  71. assert state.read_dict_edge(a, "l") is None