[tracker/wip/carlosg/graphs: 3/12] libtracker-direct: Fix notification of create events
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/wip/carlosg/graphs: 3/12] libtracker-direct: Fix notification of create events
- Date: Wed, 29 Apr 2020 20:33:16 +0000 (UTC)
commit da56fb7df333424b3e7338d6fcc81520862b731f
Author: Carlos Garnacho <carlosg gnome org>
Date: Thu Apr 23 11:59:52 2020 +0200
libtracker-direct: Fix notification of create events
Our TrackerNotifier machinery informs of changes per rdf:type, the
logic is as follows:
- If the property being added is "<x> rdf:type <class>" and the
class matches the one being notified, this is a CREATE event
- Anything else (incl rdf:type additions of other classes) is just
an "update" to the class being notified.
We were looking the class from the wrong property, thus failed to
find a class, thus everything were updates. It is the object holding
the class, not the predicate.
The functional test seemed to just follow along, fix the expected
results, as we now do get CREATE events as expected.
src/libtracker-direct/tracker-direct.c | 2 +-
tests/functional-tests/notifier.py | 22 +++++++++++-----------
2 files changed, 12 insertions(+), 12 deletions(-)
---
diff --git a/src/libtracker-direct/tracker-direct.c b/src/libtracker-direct/tracker-direct.c
index 1994579ca..c4798c2b0 100644
--- a/src/libtracker-direct/tracker-direct.c
+++ b/src/libtracker-direct/tracker-direct.c
@@ -404,7 +404,7 @@ insert_statement_cb (gint graph_id,
if (predicate_id == tracker_property_get_id (rdf_type)) {
const gchar *uri;
- uri = tracker_ontologies_get_uri_by_id (ontologies, predicate_id);
+ uri = tracker_ontologies_get_uri_by_id (ontologies, object_id);
new_class = tracker_ontologies_get_class_by_uri (ontologies, uri);
}
diff --git a/tests/functional-tests/notifier.py b/tests/functional-tests/notifier.py
index fc708f92b..5c52f795f 100644
--- a/tests/functional-tests/notifier.py
+++ b/tests/functional-tests/notifier.py
@@ -98,10 +98,10 @@ class TrackerNotifierTests():
# validate results
self.assertEqual(len(self.results_deletes), 0)
- self.assertEqual(len(self.results_inserts), 0)
- self.assertEqual(len(self.results_updates), 1)
- print(self.results_updates[0])
- assert self.results_updates[0].get_urn() == 'test://signals-contact-add'
+ self.assertEqual(len(self.results_inserts), 1)
+ self.assertEqual(len(self.results_updates), 0)
+ print(self.results_inserts[0])
+ assert self.results_inserts[0].get_urn() == 'test://signals-contact-add'
def test_02_remove_contact(self):
CONTACT = """
@@ -121,8 +121,8 @@ class TrackerNotifierTests():
# Validate results:
self.assertEqual(len(self.results_deletes), 1)
- self.assertEqual(len(self.results_updates), 1)
- self.assertEqual(len(self.results_inserts), 0)
+ self.assertEqual(len(self.results_updates), 0)
+ self.assertEqual(len(self.results_inserts), 1)
def test_03_update_contact(self):
self.tracker.update(
@@ -133,8 +133,8 @@ class TrackerNotifierTests():
"INSERT { <test://signals-contact-update> nco:fullname 'wohoo'}")
self.__wait_for_signal()
- self.assertEqual(len(self.results_updates), 2)
- self.assertEqual(len(self.results_inserts), 0)
+ self.assertEqual(len(self.results_updates), 1)
+ self.assertEqual(len(self.results_inserts), 1)
self.assertEqual(len(self.results_deletes), 0)
def test_04_fullupdate_contact(self):
@@ -145,14 +145,14 @@ class TrackerNotifierTests():
self.tracker.update ("""
DELETE { <test://signals-contact-fullupdate> nco:fullname ?x }
WHERE { <test://signals-contact-fullupdate> a nco:PersonContact; nco:fullname ?x }
-
+
INSERT { <test://signals-contact-fullupdate> nco:fullname 'second value'}
""")
self.__wait_for_signal()
self.assertEqual(len(self.results_deletes), 0)
- self.assertEqual(len(self.results_inserts), 0)
- self.assertEqual(len(self.results_updates), 2)
+ self.assertEqual(len(self.results_inserts), 1)
+ self.assertEqual(len(self.results_updates), 1)
class TrackerLocalNotifierTest (fixtures.TrackerSparqlDirectTest, TrackerNotifierTests):
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]