MCPcopy Create free account
hub / github.com/RedisGraph/RedisGraph / test01_save_load

Method test01_save_load

tests/flow/test_persistency.py:93–142  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

91 return dense_graph
92
93 def test01_save_load(self):
94 graph_names = ["G", "{tag}_G"]
95 for graph_name in graph_names:
96 graph = self.populate_graph(graph_name)
97 for i in range(2):
98 if i == 1:
99 # Save RDB & Load from RDB
100 self.env.dumpAndReload()
101
102 # Verify
103 # Expecting 5 person entities.
104 query = """MATCH (p:person) RETURN COUNT(p)"""
105 actual_result = graph.query(query)
106 nodeCount = actual_result.result_set[0][0]
107 self.env.assertEquals(nodeCount, 5)
108
109 query = """MATCH (p:person) WHERE p.name='Alon' RETURN COUNT(p)"""
110 actual_result = graph.query(query)
111 nodeCount = actual_result.result_set[0][0]
112 self.env.assertEquals(nodeCount, 1)
113
114 # Expecting 3 country entities.
115 query = """MATCH (c:country) RETURN COUNT(c)"""
116 actual_result = graph.query(query)
117 nodeCount = actual_result.result_set[0][0]
118 self.env.assertEquals(nodeCount, 3)
119
120 query = """MATCH (c:country) WHERE c.name = 'Israel' RETURN COUNT(c)"""
121 actual_result = graph.query(query)
122 nodeCount = actual_result.result_set[0][0]
123 self.env.assertEquals(nodeCount, 1)
124
125 # Expecting 2 visit edges.
126 query = """MATCH (n:person)-[e:visit]->(c:country) WHERE e.purpose='pleasure' RETURN COUNT(e)"""
127 actual_result = graph.query(query)
128 edgeCount = actual_result.result_set[0][0]
129 self.env.assertEquals(edgeCount, 2)
130
131 # Verify indices exists
132 indices = graph.query("""CALL db.indexes()""").result_set
133 expected_indices = [
134 ['exact-match', 'country', ['name', 'population'], 'english', [], 'NODE'],
135 ['exact-match', 'person', ['name', 'height'], 'english', [], 'NODE'],
136 ['full-text', 'person', ['text'], 'english', ['a', 'b'], 'NODE'],
137 ['exact-match', 'visit', ['_src_id', '_dest_id', 'purpose'], 'english', [], 'RELATIONSHIP']
138 ]
139
140 self.env.assertEquals(len(indices), len(expected_indices))
141 for index in indices:
142 self.env.assertIn(index, indices)
143
144 # Verify that edges are not modified after entity deletion
145 def test02_deleted_entity_migration(self):

Callers

nothing calls this directly

Calls 2

populate_graphMethod · 0.95
queryMethod · 0.45

Tested by

no test coverage detected