@@ -131,12 +131,8 @@ def wait_for_field_match(self,
131
131
at `key` in the specified table. This method will wait for the
132
132
fields to exist.
133
133
134
- NOTE: We suggest you only use this function if:
135
- 1) the entry already exists, and
136
- 2) you expect certain fields to change
137
-
138
- Otherwise, it is more efficient to use `wait_for_entry` and check
139
- for the expected fields after the entry has been retrieved.
134
+ Note:
135
+ This method does not check for an exact match.
140
136
141
137
Args:
142
138
table_name (str): The name of the table where the entry is
@@ -154,7 +150,7 @@ def wait_for_field_match(self,
154
150
155
151
def _access_function ():
156
152
fv_pairs = self .get_entry (table_name , key )
157
- return (expected_fields . items () <= fv_pairs .items (), fv_pairs )
153
+ return (all ( fv_pairs . get ( k ) == v for k , v in expected_fields .items () ), fv_pairs )
158
154
159
155
return wait_for_result (_access_function , polling_config )
160
156
@@ -208,3 +204,57 @@ def _access_function():
208
204
return (len (keys ) == num_keys , keys )
209
205
210
206
return wait_for_result (_access_function , polling_config )
207
+
208
+ def wait_for_matching_keys (self ,
209
+ table_name ,
210
+ expected_keys ,
211
+ polling_config = DEFAULT_POLLING_CONFIG ):
212
+ """
213
+ Checks if the specified keys exist in the table. This method
214
+ will wait for the keys to exist.
215
+
216
+ Args:
217
+ table_name (str): The name of the table from which to fetch
218
+ the keys.
219
+ expected_keys (List[str]): The keys we expect to see in the
220
+ table.
221
+ polling_config (PollingConfig): The parameters to use to poll
222
+ the db.
223
+
224
+ Returns:
225
+ List[str]: The keys stored in the table. If no keys are found,
226
+ then an empty List will be returned.
227
+ """
228
+
229
+ def _access_function ():
230
+ keys = self .get_keys (table_name )
231
+ return (all (key in keys for key in expected_keys ), keys )
232
+
233
+ return wait_for_result (_access_function , polling_config )
234
+
235
+ def wait_for_deleted_keys (self ,
236
+ table_name ,
237
+ deleted_keys ,
238
+ polling_config = DEFAULT_POLLING_CONFIG ):
239
+ """
240
+ Checks if the specified keys no longer exist in the table. This
241
+ method will wait for the keys to be deleted.
242
+
243
+ Args:
244
+ table_name (str): The name of the table from which to fetch
245
+ the keys.
246
+ deleted_keys (List[str]): The keys we expect to be removed from
247
+ the table.
248
+ polling_config (PollingConfig): The parameters to use to poll
249
+ the db.
250
+
251
+ Returns:
252
+ List[str]: The keys stored in the table. If no keys are found,
253
+ then an empty List will be returned.
254
+ """
255
+
256
+ def _access_function ():
257
+ keys = self .get_keys (table_name )
258
+ return (all (key not in keys for key in deleted_keys ), keys )
259
+
260
+ return wait_for_result (_access_function , polling_config )
0 commit comments