summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorSiegfried-Angel Gevatter Pujals <siegfried@gevatter.com>2012-10-05 18:50:16 +0200
committerSiegfried-Angel Gevatter Pujals <siegfried@gevatter.com>2012-10-05 18:50:16 +0200
commitd0d3c106bd9ea75ec96ea121886209d47eac357f (patch)
tree2435d12759982f313d4ea6d39d93029ddcfc85f3 /test
parentebaa5de68636918ea96b7a414e406564a3f39e51 (diff)
downloadzeitgeist-d0d3c106bd9ea75ec96ea121886209d47eac357f.tar.gz
Some test fixes. Update NEWS.
This is the first batch of test fixes after increasing the restrictions on what events can be logged.
Diffstat (limited to 'test')
-rw-r--r--test/dbus/blacklist-test.py30
-rw-r--r--test/dbus/dsr-test.py29
-rw-r--r--test/dbus/engine-test.py29
-rw-r--r--test/dbus/histogram-test.py7
-rw-r--r--test/dbus/monitor-test.py2
-rw-r--r--test/dbus/testutils.py2
6 files changed, 73 insertions, 26 deletions
diff --git a/test/dbus/blacklist-test.py b/test/dbus/blacklist-test.py
index 6f572f05..4933d285 100644
--- a/test/dbus/blacklist-test.py
+++ b/test/dbus/blacklist-test.py
@@ -7,7 +7,7 @@
# Copyright © 2010 Markus Korn <thekorn@gmx.de>
# Copyright © 2010 Siegfried-Angel Gevatter Pujals <siegfried@gevatter.com>
# Copyright © 2011 Manish Sinha <manishsinha@ubuntu.com>
-# Copyright © 2011 Collabora Ltd.
+# Copyright © 2011-2012 Collabora Ltd.
# By Siegfried-Angel Gevatter Pujals <siegfried@gevatter.com>
#
# This program is free software: you can redistribute it and/or modify
@@ -110,9 +110,10 @@ class BlacklistTest(RemoteTestCase):
def testApplyBlacklistWithTwoTemplates(self):
# Setup an event we'll use to test insertions
event = Event.new_for_values(
- timestamp = 1,
+ timestamp = 0,
interpretation=Interpretation.ACCESS_EVENT,
manifestation=Manifestation.SCHEDULED_ACTIVITY,
+ actor="actor",
subject_uri="blarg")
# With no blacklisted templates we can insert it without problems
@@ -169,13 +170,17 @@ class BlacklistTest(RemoteTestCase):
# And check that it works
self._assert_insert_blocked(Event.new_for_values(
+ interpretation="a", manifestation="b", actor="c",
subject_uri="New York is a city"))
self._assert_insert_allowed(Event.new_for_values(
+ interpretation="a", manifestation="b", actor="c",
subject_uri="New York is a city NOT"))
self._assert_insert_allowed(Event.new_for_values(
+ interpretation="a", manifestation="b", actor="c",
subject_uri="Do you like cheese?"))
self._assert_insert_allowed(Event.new_for_values(
interpretation=Interpretation.MOVE_EVENT,
+ manifestation="b", actor="c",
subject_uri="kung fu",
subject_current_uri="New York is a city"))
@@ -189,12 +194,16 @@ class BlacklistTest(RemoteTestCase):
# And check that the blacklisting works
self._assert_insert_blocked(Event.new_for_values(
+ interpretation="a", manifestation="b", actor="c",
subject_uri=u"çàrßá€"))
self._assert_insert_blocked(Event.new_for_values(
+ interpretation="a", manifestation="b", actor="c",
subject_uri=u"hello"))
self._assert_insert_allowed(Event.new_for_values(
+ interpretation="a", manifestation="b", actor="c",
subject_uri=u"hola"))
self._assert_insert_allowed(Event.new_for_values(
+ interpretation="a", manifestation="b", actor="c",
subject_uri=u"çàrßá"))
def testApplyBlacklistForEventWithEmptyCurrentURI(self):
@@ -205,11 +214,16 @@ class BlacklistTest(RemoteTestCase):
# Blocking the current_uri works
self._assert_insert_blocked(Event.new_for_values(
interpretation=Interpretation.MOVE_EVENT,
+ manifestation="manifestation",
+ actor="actor",
+ subject_uri="unrelated",
subject_current_uri="t"))
# But if we only set uri (and leave it up to Zeitgeist to set current_uri
# to the same value?
- self._assert_insert_blocked(Event.new_for_values(subject_uri="t"))
+ self._assert_insert_blocked(Event.new_for_values(
+ interpretation="a", manifestation="b", actor="c",
+ subject_uri="t"))
def testApplyBlacklistWithWildcardInURI(self):
# We blacklist some particular URIs
@@ -219,16 +233,22 @@ class BlacklistTest(RemoteTestCase):
# And check that the blacklisting works
self._assert_insert_blocked(Event.new_for_values(
+ interpretation="a", manifestation="b", actor="c",
subject_uri=u"block me"))
self._assert_insert_blocked(Event.new_for_values(
+ interpretation="a", manifestation="b", actor="c",
subject_uri=u"block me*"))
self._assert_insert_blocked(Event.new_for_values(
+ interpretation="a", manifestation="b", actor="c",
subject_uri=u"block me now"))
self._assert_insert_blocked(Event.new_for_values(
+ interpretation="a", manifestation="b", actor="c",
subject_uri=u"block meß :)"))
self._assert_insert_allowed(Event.new_for_values(
+ interpretation="a", manifestation="b", actor="c",
subject_uri=u"block mNOT"))
self._assert_insert_allowed(Event.new_for_values(
+ interpretation="a", manifestation="b", actor="c",
subject_uri=u"nblock me"))
def _get_blacklist_iface(self):
@@ -257,7 +277,7 @@ class BlacklistTest(RemoteTestCase):
mainloop = self.create_mainloop()
template1 = Event.new_for_values(
- timestamp=0,
+ timestamp=1349453012265,
interpretation=Interpretation.ACCESS_EVENT,
subject_uri="http://nothingtoseehere.gov")
@@ -306,3 +326,5 @@ class BlacklistTest(RemoteTestCase):
if __name__ == "__main__":
unittest.main()
+
+# vim:noexpandtab:ts=4:sw=4
diff --git a/test/dbus/dsr-test.py b/test/dbus/dsr-test.py
index 4031ddca..e7b934de 100644
--- a/test/dbus/dsr-test.py
+++ b/test/dbus/dsr-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>
#
@@ -169,27 +169,30 @@ class ZeitgeistRemoteDataSourceRegistryTest(testutils.RemoteTestCase):
self.client._registry.RegisterDataSource(*self._ds1)
ds = list(self.client._registry.GetDataSources())[0]
self.assertEquals(ds[DataSource.Enabled], True)
-
+
# Now we can choose to disable it...
self.client._registry.SetDataSourceEnabled(self._ds1[0], False)
ds = list(self.client._registry.GetDataSources())[0]
self.assertEquals(ds[DataSource.Enabled], False)
-
- ids = self.insertEventsAndWait([Event.new_for_values(
- subject_manifestation = "!stfu:File")])
-
+
+ event = Event.new_for_values(
+ interpretation="interpretation",
+ manifestation="manifestation",
+ actor="actor",
+ subject_uri="some uri",
+ subject_manifestation="!stfu:File")
+
+ # ... which will block its events from being inserted
+ ids = self.insertEventsAndWait([event])
self.assertEquals(ids[0], 0)
-
+
# And enable it again!
self.client._registry.SetDataSourceEnabled(self._ds1[0], True)
ds = list(self.client._registry.GetDataSources())[0]
self.assertEquals(ds[DataSource.Enabled], True)
-
- ids = self.insertEventsAndWait([Event.new_for_values(
- subject_manifestation = "!stfu:File")])
-
- self.assertEquals(ids[0], 1)
+ ids = self.insertEventsAndWait([event])
+ self.assertEquals(ids[0], 1)
def testGetDataSourceFromId(self):
# Insert a data-source -- and then retrieve it by id
@@ -283,3 +286,5 @@ class ZeitgeistRemoteDataSourceRegistryTest(testutils.RemoteTestCase):
if __name__ == "__main__":
unittest.main()
+
+# vim:noexpandtab:ts=4:sw=4
diff --git a/test/dbus/engine-test.py b/test/dbus/engine-test.py
index 7217a9ba..c7f2df1e 100644
--- a/test/dbus/engine-test.py
+++ b/test/dbus/engine-test.py
@@ -1,13 +1,13 @@
#! /usr/bin/python
# -.- coding: utf-8 -.-
-# remote-test.py
+# engine-test.py
#
# Copyright © 2009-2011 Seif Lotfy <seif@lotfy.com>
# 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>
#
@@ -194,7 +194,8 @@ class ZeitgeistEngineTest(testutils.RemoteTestCase):
# revision rainct@ubuntu.com-20091128164327-j8ez3fsifd1gygkr (1185)
# Fix _build_templates so that it works when the Subject is empty.
self.testSingleInsertGet()
- result = self.findEventIdsAndWait([Event.new_for_values(interpretation=Interpretation.LEAVE_EVENT)])
+ result = self.findEventIdsAndWait([Event.new_for_values(
+ interpretation=Interpretation.LEAVE_EVENT)])
self.assertEquals(0, len(result))
def testFindFive(self):
@@ -332,8 +333,12 @@ class ZeitgeistEngineTest(testutils.RemoteTestCase):
def testGetWithMultipleSubjects(self):
subj1 = Subject.new_for_values(uri="file:///tmp/foo.txt")
subj2 = Subject.new_for_values(uri="file:///tmp/loo.txt")
- event_template = Event.new_for_values(subjects=[subj1, subj2])
- result = self.insertEventsAndWait([event_template])
+ event = Event.new_for_values(
+ interpretation=Interpretation.ACCESS_EVENT,
+ manifestation=Interpretation.FILE_DATA_OBJECT,
+ actor="application://test.desktop",
+ subjects=[subj1, subj2])
+ result = self.insertEventsAndWait([event])
events = self.getEventsAndWait(result)
self.assertEquals(2, len(events[0].subjects))
self.assertEquals("file:///tmp/foo.txt", events[0].subjects[0].uri)
@@ -342,11 +347,15 @@ class ZeitgeistEngineTest(testutils.RemoteTestCase):
def testFindEventIdsWithMultipleSubjects(self):
subj1 = Subject.new_for_values(uri="file:///tmp/foo.txt")
subj2 = Subject.new_for_values(uri="file:///tmp/loo.txt")
- event = Event.new_for_values(subjects=[subj1, subj2])
+ event = Event.new_for_values(
+ interpretation=Interpretation.ACCESS_EVENT,
+ manifestation=Interpretation.FILE_DATA_OBJECT,
+ subjects=[subj1, subj2])
orig_ids = self.insertEventsAndWait([event])
- result_ids = self.findEventIdsAndWait([Event()], num_events = 0, result_type = 1)
- self.assertEquals(orig_ids, list(result_ids)) #FIXME: We need subjects of the same event to be merged
-
+ result_ids = self.findEventIdsAndWait([Event()], num_events=0,
+ result_type=ResultType.LEAST_RECENT_EVENTS)
+ self.assertEquals(orig_ids, list(result_ids))
+
def testFindEventsEventTemplate(self):
import_events("test/data/five_events.js", self)
subj = Subject.new_for_values(interpretation="stfu:Bee")
@@ -1137,3 +1146,5 @@ class ResultTypeTest(testutils.RemoteTestCase):
if __name__ == "__main__":
unittest.main()
+
+# vim:noexpandtab:ts=4:sw=4
diff --git a/test/dbus/histogram-test.py b/test/dbus/histogram-test.py
index 6d30b3f0..dc79b712 100644
--- a/test/dbus/histogram-test.py
+++ b/test/dbus/histogram-test.py
@@ -69,7 +69,10 @@ class HistogramTest(RemoteTestCase):
self.histogram = dbus.Interface(obj, "org.gnome.zeitgeist.Histogram")
def _createEventOne(self):
- ev = Event.new_for_values(interpretation=Interpretation.ACCESS_EVENT,
+ ev = Event.new_for_values(
+ interpretation=Interpretation.ACCESS_EVENT,
+ manifestation=Manifestation.FILE_DATA_OBJECT,
+ actor="application://test.desktop",
subject_uri="file://sisisisisisi")
ev.manifestation = Manifestation.USER_ACTIVITY
@@ -104,3 +107,5 @@ class HistogramTest(RemoteTestCase):
if __name__ == "__main__":
unittest.main()
+
+# vim:noexpandtab:ts=4:sw=4
diff --git a/test/dbus/monitor-test.py b/test/dbus/monitor-test.py
index d3c212f8..62db8104 100644
--- a/test/dbus/monitor-test.py
+++ b/test/dbus/monitor-test.py
@@ -317,3 +317,5 @@ class ZeitgeistMonitorTest(testutils.RemoteTestCase):
if __name__ == "__main__":
unittest.main()
+
+# vim:noexpandtab:ts=4:sw=4
diff --git a/test/dbus/testutils.py b/test/dbus/testutils.py
index e964b574..37e55462 100644
--- a/test/dbus/testutils.py
+++ b/test/dbus/testutils.py
@@ -445,3 +445,5 @@ class DBusPrivateMessageBus(object):
if ignore_errors:
return e
raise
+
+# vim:noexpandtab:ts=4:sw=4