zeitgeist team mailing list archive
-
zeitgeist team
-
Mailing list archive
-
Message #03871
[Branch ~zeitgeist/zeitgeist/bluebird] Rev 210: Move test in remote-test.py to new class.
------------------------------------------------------------
revno: 210
committer: Siegfried-Angel Gevatter Pujals <siegfried@xxxxxxxxxxxx>
branch nick: bluebird
timestamp: Thu 2011-09-01 18:40:30 +0200
message:
Move test in remote-test.py to new class.
modified:
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 'test/dbus/remote-test.py'
--- test/dbus/remote-test.py 2011-08-25 16:19:38 +0000
+++ test/dbus/remote-test.py 2011-09-01 16:40:30 +0000
@@ -60,8 +60,70 @@
retrieved_events = self.getEventsAndWait(ids)
self.assertEquals(1, len(retrieved_events))
self.assertEventsEqual(retrieved_events[0], events[0])
-
+
+ def testUnicodeInsert(self):
+ events = parse_events("test/data/unicode_event.js")
+ ids = self.insertEventsAndWait(events)
+ 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]
+ result = self.getEventsAndWait(ids)
+ self.assertEquals(len(filter(None, result)), len(events))
+ self.assertEquals(len(filter(lambda event: event is None, result)), 2)
+
+ def testInsertAndDeleteEvent(self):
+ # Insert an event
+ events = parse_events("test/data/single_event.js")
+ ids = self.insertEventsAndWait(events)
+
+ # Delete it, make sure the returned time range is correct
+ time_range = self.deleteEventsAndWait(ids)
+ self.assertEquals(time_range[0], time_range[1])
+ self.assertEquals(time_range[0], int(events[0].timestamp))
+
+ # Make sure the event is gone
+ retrieved_events = self.getEventsAndWait(ids)
+ self.assertEquals(retrieved_events[0], None)
+
+ def testDeleteNonExistantEvent(self):
+ # Insert an event (populate the database so it isn't empty)
+ events = parse_events("test/data/single_event.js")
+ ids = self.insertEventsAndWait(events)
+
+ # Try deleting a non-existant event
+ events = parse_events("test/data/single_event.js")
+ time_range = self.deleteEventsAndWait([int(ids[0]) + 1000])
+ self.assertEquals(time_range[0], time_range[1])
+ self.assertEquals(time_range[0], -1)
+
+ # Make sure the inserted event is still there
+ retrieved_events = self.getEventsAndWait(ids)
+ self.assertEquals(1, len(retrieved_events))
+ self.assertEventsEqual(retrieved_events[0], events[0])
+
+ def testDeleteTwoSimilarEvents(self):
+ # Insert a couple similar events
+ event1 = parse_events("test/data/single_event.js")[0]
+ event2 = Event(event1)
+ event2.timestamp = int(event1.timestamp) + 1
+ ids = self.insertEventsAndWait([event1, event2])
+
+ # Try deleting one of them
+ self.deleteEventsAndWait([ids[0]])
+
+ # Make sure it's gone, but the second one is still there
+ retrieved_events = self.getEventsAndWait(ids)
+ self.assertEquals(retrieved_events[0], None)
+ self.assertEventsEqual(retrieved_events[1], event2)
+
+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,
@@ -100,7 +162,7 @@
# Search for everything
ids = self.findEventIdsAndWait([], num_events=3)
- self.assertEquals(3, len(ids)) # (we can not trust the ids because we don't have a clean test environment)
+ self.assertEquals(3, len(ids))
# Search for some specific templates
subj_templ1 = Subject.new_for_values(manifestation=Manifestation.FILE_DATA_OBJECT)
@@ -112,65 +174,6 @@
ids = self.findEventIdsAndWait([event_template],
num_events=10)
self.assertEquals(1, len(ids))
-
- def testUnicodeInsert(self):
- events = parse_events("test/data/unicode_event.js")
- ids = self.insertEventsAndWait(events)
- 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]
- result = self.getEventsAndWait(ids)
- self.assertEquals(len(filter(None, result)), len(events))
- self.assertEquals(len(filter(lambda event: event is None, result)), 2)
-
- def testInsertAndDeleteEvent(self):
- # Insert an event
- events = parse_events("test/data/single_event.js")
- ids = self.insertEventsAndWait(events)
-
- # Delete it, make sure the returned time range is correct
- time_range = self.deleteEventsAndWait(ids)
- self.assertEquals(time_range[0], time_range[1])
- self.assertEquals(time_range[0], int(events[0].timestamp))
-
- # Make sure the event is gone
- retrieved_events = self.getEventsAndWait(ids)
- self.assertEquals(retrieved_events[0], None)
-
- def testDeleteNonExistantEvent(self):
- # Insert an event (populate the database so it isn't empty)
- events = parse_events("test/data/single_event.js")
- ids = self.insertEventsAndWait(events)
-
- # Try deleting a non-existant event
- events = parse_events("test/data/single_event.js")
- time_range = self.deleteEventsAndWait([int(ids[0]) + 1000])
- self.assertEquals(time_range[0], time_range[1])
- self.assertEquals(time_range[0], -1)
-
- # Make sure the inserted event is still there
- retrieved_events = self.getEventsAndWait(ids)
- self.assertEquals(1, len(retrieved_events))
- self.assertEventsEqual(retrieved_events[0], events[0])
-
- def testDeleteTwoSimilarEvents(self):
- # Insert a couple similar events
- event1 = parse_events("test/data/single_event.js")[0]
- event2 = Event(event1)
- event2.timestamp = int(event1.timestamp) + 1
- ids = self.insertEventsAndWait([event1, event2])
-
- # Try deleting one of them
- self.deleteEventsAndWait([ids[0]])
-
- # Make sure it's gone, but the second one is still there
- retrieved_events = self.getEventsAndWait(ids)
- self.assertEquals(retrieved_events[0], None)
- self.assertEventsEqual(retrieved_events[1], event2)
class ZeitgeistRemoteFindEventIdsTest(testutils.RemoteTestCase):
"""