Skip to content

Commit fb08ad3

Browse files
committed
Added Comments
1 parent 4ce961a commit fb08ad3

1 file changed

Lines changed: 22 additions & 1 deletion

File tree

hydra_agent/tests/test_querying.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,32 +127,42 @@ def smembers_mock_func(self, inp):
127127
return [b"TestEndpoint"]
128128

129129
def test_get_members_if(self):
130+
# query param to be passed to get_members
130131
query = "TestEndpoint members"
131132
connection_mock = self.cmq.connection
132133

134+
# making the if condition true
133135
connection_mock.keys.return_value = [b'fs:endpoints']
134136
connection_mock.smembers.side_effect = self.smembers_mock_func
137+
138+
# call to get_members
135139
self.cmq.get_members(query)
136140

141+
# checking the call made to connection_mock.execute_command with correct params
137142
connection_mock.execute_command.assert_called_with('GRAPH.QUERY', 'apidoc', """MATCH(p:collection)
138143
WHERE(p.type='TestEndpoint')
139144
RETURN p.members""")
140145

146+
# asserting that connection.sadd was not called
141147
connection_mock.sadd.assert_not_called()
142148

143149
def smembers_mock_func_else(self, inp):
144150
if inp == "fs:endpoints":
145151
return [b"TestEndpoint"]
146152

147153
def test_get_members_else(self):
154+
# query param to be passed to get_members
148155
query = "TestEndpoint members"
149156
connection_mock = self.cmq.connection
150157

158+
# making the if condition false
151159
connection_mock.keys.return_value = []
152160
connection_mock.smembers.side_effect = self.smembers_mock_func_else
153161

162+
# call to get_members
154163
self.cmq.get_members(query)
155164

165+
# asserting that connection_mock.sadd was called
156166
connection_mock.sadd.assert_called_with("fs:endpoints", "TestEndpoint")
157167

158168

@@ -162,38 +172,49 @@ def setUp(self, redis_mock):
162172
self.properties_query = PropertiesQuery()
163173

164174
def test_get_classes_properties(self):
175+
# query param for get_classes_properties
165176
query = "classClassEndpoint properties"
166177
connection_mock = self.properties_query.connection
167178

179+
# call to get_classes_properties
168180
self.properties_query.get_classes_properties(query)
169181

182+
# asserting that redis_query was called with correct params
170183
connection_mock.execute_command.assert_called_with('GRAPH.QUERY', 'apidoc', 'MATCH ( p:classes ) WHERE (p.type="ClassEndpoint") RETURN p.properties')
171184

172185
def test_get_collection_properties(self):
186+
# query param for get_collection_properties
173187
query = "collectionEndpoint properties"
174-
175188
connection_mock = self.properties_query.connection
176189

190+
# call to get_collection_properties
177191
self.properties_query.get_collection_properties(query)
178192

193+
# asserting that redis query was called with correct params
179194
connection_mock.execute_command.assert_called_with('GRAPH.QUERY', 'apidoc', 'MATCH ( p:collection ) WHERE (p.type="collectionEndpoint") RETURN p.properties')
180195

181196
def test_members_properties(self):
197+
# query param for get_members_properties
182198
query = "testMember properties"
183199

184200
connection_mock = self.properties_query.connection
185201

202+
# call to get_members_properties
186203
self.properties_query.get_members_properties(query)
187204

205+
# asserting that redis query was called with correct params
188206
connection_mock.execute_command.assert_called_with('GRAPH.QUERY', 'apidoc', 'MATCH ( p:testMember ) RETURN p.id,p.properties')
189207

190208
def test_object_properties(self):
209+
# query for get_object_property
191210
query = "object/api/TestCollection/2 properties"
192211

193212
connection_mock = self.properties_query.connection
194213

214+
# call to get_object_property
195215
self.properties_query.get_object_property(query)
196216

217+
# asserting that redis query was called with correct params
197218
connection_mock.execute_command.assert_called_with('GRAPH.QUERY', 'apidoc', 'MATCH ( p:objectTest) WHERE (p.parent_id = "/api/TestCollection/2") RETURN p.properties')
198219

199220

0 commit comments

Comments
 (0)