@@ -121,6 +121,43 @@ def _access_function():
121
121
122
122
return wait_for_result (_access_function , polling_config )
123
123
124
+ def wait_for_field_match (self ,
125
+ table_name ,
126
+ key ,
127
+ expected_fields ,
128
+ polling_config = DEFAULT_POLLING_CONFIG ):
129
+ """
130
+ Checks if the provided fields are contained in the entry stored
131
+ at `key` in the specified table. This method will wait for the
132
+ fields to exist.
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.
140
+
141
+ Args:
142
+ table_name (str): The name of the table where the entry is
143
+ stored.
144
+ key (str): The key that maps to the entry being checked.
145
+ expected_fields (dict): The fields and their values we expect
146
+ to see in the entry.
147
+ polling_config (PollingConfig): The parameters to use to poll
148
+ the db.
149
+
150
+ Returns:
151
+ Dict[str, str]: The entry stored at `key`. If no entry is found,
152
+ then an empty Dict will be returned.
153
+ """
154
+
155
+ def _access_function ():
156
+ fv_pairs = self .get_entry (table_name , key )
157
+ return (expected_fields .items () <= fv_pairs .items (), fv_pairs )
158
+
159
+ return wait_for_result (_access_function , polling_config )
160
+
124
161
def wait_for_empty_entry (self ,
125
162
table_name ,
126
163
key ,
@@ -141,7 +178,7 @@ def wait_for_empty_entry(self,
141
178
142
179
def _access_function ():
143
180
fv_pairs = self .get_entry (table_name , key )
144
- return (not fv_pairs , fv_pairs )
181
+ return (not bool ( fv_pairs ) , fv_pairs )
145
182
146
183
return wait_for_result (_access_function , polling_config )
147
184
0 commit comments