← Back to team overview

zeitgeist team mailing list archive

[Branch ~zeitgeist/zeitgeist/bluebird] Rev 263: testFindTwoOfThreeEvents: move event declarations to a new three_events.js

 

------------------------------------------------------------
revno: 263
committer: Siegfried-Angel Gevatter Pujals <siegfried@xxxxxxxxxxxx>
branch nick: bluebird
timestamp: Sun 2011-09-18 14:10:22 +0200
message:
  testFindTwoOfThreeEvents: move event declarations to a new three_events.js
added:
  test/data/three_events.js
modified:
  src/engine.vala
  test/dbus/engine-test.py
  test/dbus/remote-test.py


--
lp:~zeitgeist/zeitgeist/bluebird
https://code.launchpad.net/~zeitgeist/zeitgeist/bluebird

Your team Zeitgeist Framework Team is subscribed to branch lp:~zeitgeist/zeitgeist/bluebird.
To unsubscribe from this branch go to https://code.launchpad.net/~zeitgeist/zeitgeist/bluebird/+edit-subscription
=== modified file 'src/engine.vala'
--- src/engine.vala	2011-09-17 19:38:43 +0000
+++ src/engine.vala	2011-09-18 12:10:22 +0000
@@ -157,7 +157,7 @@
 
     public uint32[] find_event_ids (TimeRange time_range,
         GenericArray<Event> event_templates,
-        uint storage_state, uint max_events, uint result_type, 
+        uint storage_state, uint max_events, uint result_type,
         BusName? sender=null) throws EngineError
     {
         return find_event_ids_logic(time_range, event_templates, storage_state,

=== added file 'test/data/three_events.js'
--- test/data/three_events.js	1970-01-01 00:00:00 +0000
+++ test/data/three_events.js	2011-09-18 12:10:22 +0000
@@ -0,0 +1,43 @@
+[
+	{
+		"timestamp" : 400,
+		"interpretation" : "http://www.zeitgeist-project.com/ontologies/2010/01/27/zg#AccessEvent";,
+		"manifestation" : "http://www.zeitgeist-project.com/ontologies/2010/01/27/zg#UserActivity";,
+		"actor" : "Boogaloo",
+		"subjects" : [
+			{
+				"uri" : "foo://bar",
+				"interpretation" : "http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#Document";,
+				"manifestation" : "http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#FileDataObject";
+			},{
+				"uri" : "foo://meh",
+				"interpretation" : "http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#Video";,
+				"manifestation" : "http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#FileDataObject";
+			}
+		]
+	},{
+		"timestamp" : 500,
+		"interpretation" : "http://www.zeitgeist-project.com/ontologies/2010/01/27/zg#AccessEvent";,
+		"manifestation" : "http://www.zeitgeist-project.com/ontologies/2010/01/27/zg#UserActivity";,
+		"actor" : "Boogaloo with spaces! :)",
+		"subjects" : [
+			{
+				"uri" : "foo://baz",
+				"interpretation" : "http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#Image";,
+				"manifestation" : "http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#FileDataObject";
+			}
+		]
+	},{
+		"timestamp" : 600,
+		"interpretation" : "http://www.zeitgeist-project.com/ontologies/2010/01/27/zg#SendEvent";,
+		"manifestation" : "http://www.zeitgeist-project.com/ontologies/2010/01/27/zg#UserActivity";,
+		"actor" : "Boogaloo",
+		"subjects" : [
+			{
+				"uri" : "foo://quiz",
+				"interpretation" : "http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#Audio";,
+				"manifestation" : "http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#FileDataObject";
+			}
+		]
+	}
+]

=== modified file 'test/dbus/engine-test.py'
--- test/dbus/engine-test.py	2011-09-16 23:45:36 +0000
+++ test/dbus/engine-test.py	2011-09-18 12:10:22 +0000
@@ -49,6 +49,7 @@
 
 TEST_ACTOR = "/usr/share/applications/gnome-about.desktop"
 
+# FIXME: move this to a .js file
 test_event_1 = None
 def create_test_event_1():
 	ev = Event()

=== modified file 'test/dbus/remote-test.py'
--- test/dbus/remote-test.py	2011-09-01 16:40:30 +0000
+++ test/dbus/remote-test.py	2011-09-18 12:10:22 +0000
@@ -123,34 +123,8 @@
 class ZeitgeistRemoteAPITestAdvanced(testutils.RemoteTestCase):
 
 	def testFindTwoOfThreeEvents(self):
-        # FIXME: use json instead of hardcoding stuff here...
-		ev1 = Event.new_for_values(timestamp=400,
-					interpretation=Interpretation.ACCESS_EVENT,
-					manifestation=Manifestation.USER_ACTIVITY,
-					actor="Boogaloo")	
-		ev2 = Event.new_for_values(timestamp=500,
-					interpretation=Interpretation.ACCESS_EVENT,
-					manifestation=Manifestation.USER_ACTIVITY,
-					actor="Boogaloo")
-		ev3 = Event.new_for_values(timestamp=600,
-					interpretation=Interpretation.SEND_EVENT,
-					manifestation=Manifestation.USER_ACTIVITY,
-					actor="Boogaloo")
-		subj1 = Subject.new_for_values(uri="foo://bar",
-					interpretation=Interpretation.DOCUMENT,
-					manifestation=Manifestation.FILE_DATA_OBJECT)
-		subj2 = Subject.new_for_values(uri="foo://baz",
-					interpretation=Interpretation.IMAGE,
-					manifestation=Manifestation.FILE_DATA_OBJECT)
-		subj3 = Subject.new_for_values(uri="foo://quiz",
-					interpretation=Interpretation.AUDIO,
-					manifestation=Manifestation.FILE_DATA_OBJECT)
-		ev1.append_subject(subj1)
-		ev2.append_subject(subj1)
-		ev2.append_subject(subj2)
-		ev3.append_subject(subj2)
-		ev3.append_subject(subj3)
-		ids = self.insertEventsAndWait([ev1, ev2, ev3])
+		events = parse_events("test/data/three_events.js")
+		ids = self.insertEventsAndWait(events)
 		self.assertEquals(3, len(ids))
 		
 		events = self.getEventsAndWait(ids)
@@ -158,7 +132,7 @@
 		for event in events:
 			self.assertTrue(isinstance(event, Event))
 			self.assertEquals(Manifestation.USER_ACTIVITY, event.manifestation)
-			self.assertEquals("Boogaloo", event.actor)
+			self.assertTrue(event.actor.startswith("Boogaloo"))
 		
 		# Search for everything
 		ids = self.findEventIdsAndWait([], num_events=3)
@@ -168,9 +142,9 @@
 		subj_templ1 = Subject.new_for_values(manifestation=Manifestation.FILE_DATA_OBJECT)
 		subj_templ2 = Subject.new_for_values(interpretation=Interpretation.IMAGE)
 		event_template = Event.new_for_values(
-					actor="Boogaloo",
+					actor="Boogaloo*",
 					interpretation=Interpretation.ACCESS_EVENT,
-					subjects=[subj_templ1,subj_templ2])
+					subjects=[subj_templ1, subj_templ2])
 		ids = self.findEventIdsAndWait([event_template],
 						num_events=10)
 		self.assertEquals(1, len(ids))