[tracker: 1/6] functional-tests: Add await_property_changed() method
- From: Sam Thursfield <sthursfield src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker: 1/6] functional-tests: Add await_property_changed() method
- Date: Fri, 26 Dec 2014 01:01:25 +0000 (UTC)
commit 315dd05bbe37100ac76dfce14b57e7e358956188
Author: Sam Thursfield <sam afuera me uk>
Date: Sat Aug 2 02:20:11 2014 +0100
functional-tests: Add await_property_changed() method
This allows detecting when a file move has been done, and probably other
useful things too.
tests/functional-tests/common/utils/helpers.py | 40 ++++++++++++++++++++++++
1 files changed, 40 insertions(+), 0 deletions(-)
---
diff --git a/tests/functional-tests/common/utils/helpers.py b/tests/functional-tests/common/utils/helpers.py
index 5ad4a4f..d90196d 100644
--- a/tests/functional-tests/common/utils/helpers.py
+++ b/tests/functional-tests/common/utils/helpers.py
@@ -431,6 +431,46 @@ class StoreHelper (Helper):
return
+ def await_property_changed (self, subject_id, property_uri):
+ """
+ Block until a property of a resource is updated or inserted.
+ """
+ assert (self.inserts_match_function == None)
+
+ property_id = self.get_resource_id_by_uri(property_uri)
+
+ def find_property_change (inserts_list):
+ matched = False
+ remaining_events = []
+
+ for insert in inserts_list:
+ if insert[1] == subject_id and insert[2] == property_id:
+ log("Matched property change: %s" % str(insert))
+ matched = True
+ else:
+ remaining_events += [insert]
+
+ return matched, remaining_events
+
+ def match_cb (inserts_list):
+ matched, remaining_events = find_property_change (inserts_list)
+ exit_loop = matched
+ return exit_loop, remaining_events
+
+ # Check the list of previously received events for matches
+ (existing_match, self.inserts_list) = find_property_change (self.inserts_list)
+
+ if not existing_match:
+ self._enable_await_timeout ()
+ self.inserts_match_function = match_cb
+ # Run the event loop until the correct notification arrives
+ self.loop.run ()
+ self.inserts_match_function = None
+
+ if self.graph_updated_timed_out:
+ raise Exception ("Timeout waiting for property change, subject %i "
+ "property %s" % (subject_id, property_uri))
+
def query (self, query, timeout=5000):
try:
return self.resources.SparqlQuery (query, timeout=timeout)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]