summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorSiegfried-Angel Gevatter Pujals <siegfried.gevatter@collabora.co.uk>2012-09-25 16:36:24 +0200
committerSiegfried-Angel Gevatter Pujals <siegfried.gevatter@collabora.co.uk>2012-09-25 16:36:24 +0200
commite8ac4b2860bdb935516972605177e847c5cb8712 (patch)
tree714202edb805e2bae2ebcfa55757e48573ff3801 /test
parentd2e179479d4af080022f0fe45454b2af9feae894 (diff)
downloadzeitgeist-e8ac4b2860bdb935516972605177e847c5cb8712.tar.gz
Require event interp/manif/actor and subject uri
Those fields are essential event information. If they are missing, the event is considered invalid and rejected. This commit also adds some test cases for those cases.
Diffstat (limited to 'test')
-rw-r--r--test/data/incomplete_events.js72
-rw-r--r--test/dbus/remote-test.py44
2 files changed, 113 insertions, 3 deletions
diff --git a/test/data/incomplete_events.js b/test/data/incomplete_events.js
index b25e2f21..680ce0fd 100644
--- a/test/data/incomplete_events.js
+++ b/test/data/incomplete_events.js
@@ -52,5 +52,77 @@
"manifestation" : "something else"
}
]
+ },{
+ "timestamp" : 1300,
+ "interpretation" : "",
+ "manifestation" : "no interpretation",
+ "actor" : "actor",
+ "subjects" : [
+ {
+ "uri" : "foo://bar",
+ "interpretation" : "sint",
+ "manifestation" : "sman"
+ }
+ ]
+ },{
+ "timestamp" : 1300,
+ "interpretation" : "no manifestation",
+ "manifestation" : "",
+ "actor" : "actor",
+ "subjects" : [
+ {
+ "uri" : "foo://bar",
+ "interpretation" : "sint",
+ "manifestation" : "sman"
+ }
+ ]
+ },{
+ "timestamp" : 1400,
+ "interpretation" : "#AccessEvent",
+ "manifestation" : "#UserActivity",
+ "actor" : "",
+ "subjects" : [
+ {
+ "uri" : "foo://bar",
+ "interpretation" : "sint",
+ "manifestation" : "sman"
+ }
+ ]
+ },{
+ "timestamp" : 500,
+ "interpretation" : "#AccessEvent",
+ "manifestation" : "#UserActivity",
+ "actor" : "Void",
+ "subjects" : [
+ {
+ "uri" : "file://baz0",
+ "mimetype" : "text/x-python",
+ "interpretation" : "",
+ "manifestation" : ""
+ },{
+ "uri" : "file://baz1",
+ "mimetype" : "text/x-python",
+ "interpretation" : "a",
+ "manifestation" : ""
+ },{
+ "uri" : "",
+ "mimetype" : "missing/URI",
+ "interpretation" : "",
+ "manifestation" : "b"
+ }
+ ]
+ },{
+ "timestamp" : 1799,
+ "interpretation" : "#AccessEvent",
+ "manifestation" : "#UserActivity",
+ "actor" : "application://foo.desktop",
+ "subjects" : [
+ {
+ "uri" : "file:///unknown-mimetype-file",
+ "mimetype" : "",
+ "interpretation" : "",
+ "manifestation" : ""
+ }
+ ]
}
]
diff --git a/test/dbus/remote-test.py b/test/dbus/remote-test.py
index 87c4a64f..1474266f 100644
--- a/test/dbus/remote-test.py
+++ b/test/dbus/remote-test.py
@@ -7,7 +7,7 @@
# Copyright © 2009-2011 Siegfried-Angel Gevatter Pujals <siegfried@gevatter.com>
# Copyright © 2009-2011 Mikkel Kamstrup Erlandsen <mikkel.kamstrup@gmail.com>
# Copyright © 2009-2011 Markus Korn <thekorn@gmx.de>
-# Copyright © 2011 Collabora Ltd.
+# Copyright © 2011-2012 Collabora Ltd.
# By Siegfried-Angel Gevatter Pujals <siegfried@gevatter.com>
# By Seif Lotfy <seif@lotfy.com>
#
@@ -67,7 +67,7 @@ class ZeitgeistRemoteAPITest(testutils.RemoteTestCase):
self.assertEquals(len(ids), len(events))
result_events = self.getEventsAndWait(ids)
self.assertEquals(len(ids), len(result_events))
-
+
def testGetEvents(self):
events = parse_events("test/data/five_events.js")
ids = self.insertEventsAndWait(events) + [1000, 2000]
@@ -226,7 +226,7 @@ class ZeitgeistRemoteAPITestAdvanced(testutils.RemoteTestCase):
def testInsertWithEmptySubjectInterpretationManifestation(self):
events = parse_events("test/data/incomplete_events.js")
- ids = self.insertEventsAndWait(events)
+ ids = self.insertEventsAndWait(events[:3])
self.assertEquals(3, len(ids))
event = self.getEventsAndWait([ids[0]])[0]
@@ -247,6 +247,42 @@ class ZeitgeistRemoteAPITestAdvanced(testutils.RemoteTestCase):
self.assertEquals("something else", event.subjects[0].manifestation)
self.assertEquals("#Audio", event.subjects[0].interpretation)
+ def testInsertWithEmptySubjectMimeType(self):
+ events = parse_events("test/data/incomplete_events.js")
+ ids = self.insertEventsAndWait([events[7]])
+ self.assertEquals(1, len(ids))
+
+ event = self.getEventsAndWait([ids[0]])[0]
+ self.assertEquals(1, len(event.subjects))
+
+ subject = event.subjects[0]
+ self.assertEquals("file:///unknown-mimetype-file", subject.uri)
+ self.assertEquals("", subject.mimetype)
+ self.assertEquals(Manifestation.FILE_DATA_OBJECT, subject.manifestation) # FIXME
+ self.assertEquals("", subject.interpretation) # FIXME
+
+ def testInsertIncompleteEvent(self):
+ events = parse_events("test/data/incomplete_events.js")
+
+ # Missing interpretation
+ ids = self.insertEventsAndWait([events[3]])
+ self.assertEquals(0, len(ids))
+
+ # Missing manifestation
+ ids = self.insertEventsAndWait([events[4]])
+ self.assertEquals(0, len(ids))
+
+ # Missing actor
+ ids = self.insertEventsAndWait([events[5]])
+ self.assertEquals(0, len(ids))
+
+ def testInsertIncompleteSubject(self):
+ events = parse_events("test/data/incomplete_events.js")
+
+ # Missing one subject URI
+ ids = self.insertEventsAndWait([events[6]])
+ self.assertEquals(0, len(ids))
+
class ZeitgeistRemoteFindEventIdsTest(testutils.RemoteTestCase):
"""
Test cases with basic tests for FindEventIds.
@@ -487,3 +523,5 @@ class ZeitgeistRemotePropertiesTest(testutils.RemoteTestCase):
if __name__ == "__main__":
unittest.main()
+
+# vim:noexpandtab:ts=4:sw=4