[Commits] (twl) Use refactored RepositoryTestCase
commits at osafoundation.org
commits at osafoundation.org
Wed Sep 1 15:38:12 PDT 2004
Commit by: twl
Modified files:
chandler/repository/query/tests/TestCompoundQueries.py 1.5 1.6
chandler/repository/query/tests/TestNotification.py 1.4 1.5
chandler/repository/query/tests/TestSimpleQueries.py 1.8 1.9
Log message:
Use refactored RepositoryTestCase
Add mailbox query test
Add test for variables in where clause
ViewCVS links:
http://cvs.osafoundation.org/index.cgi/chandler/repository/query/tests/TestCompoundQueries.py.diff?r1=text&tr1=1.5&r2=text&tr2=1.6
http://cvs.osafoundation.org/index.cgi/chandler/repository/query/tests/TestNotification.py.diff?r1=text&tr1=1.4&r2=text&tr2=1.5
http://cvs.osafoundation.org/index.cgi/chandler/repository/query/tests/TestSimpleQueries.py.diff?r1=text&tr1=1.8&r2=text&tr2=1.9
Index: chandler/repository/query/tests/TestCompoundQueries.py
diff -u chandler/repository/query/tests/TestCompoundQueries.py:1.5 chandler/repository/query/tests/TestCompoundQueries.py:1.6
--- chandler/repository/query/tests/TestCompoundQueries.py:1.5 Thu Aug 26 15:43:15 2004
+++ chandler/repository/query/tests/TestCompoundQueries.py Wed Sep 1 15:38:10 2004
@@ -1,6 +1,6 @@
-__revision__ = "$Revision: 1.5 $"
-__date__ = "$Date: 2004/08/26 22:43:15 $"
+__revision__ = "$Revision: 1.6 $"
+__date__ = "$Date: 2004/09/01 22:38:10 $"
__copyright__ = "Copyright (c) 2004 Open Source Applications Foundation"
__license__ = "http://osafoundation.org/Chandler_0.1_license_terms.htm"
@@ -20,19 +20,10 @@
results = self._executeQuery(u"intersect(for i in '//Schema/Core/Kind' where contains(i.itsName,'o'),for i in '//Schema/Core/Kind' where contains(i.itsName,'t'))")
#@@@ TODO better result check
# self._checkQuery(lambda i: not i.hasAttributeValue("superKinds"), results)
- for i in results:
- print i
def testUnionQuery(self):
""" Test a union query """
- import application
- import application.Globals as Globals
import osaf.contentmodel.tests.GenerateItems as GenerateItems
- from osaf.framework.notifications.NotificationManager import NotificationManager
- import osaf.contentmodel.ItemCollection as ItemCollection
-
- Globals.repository = self.rep
- Globals.notificationManager = NotificationManager()
self.loadParcels(
['http://osafoundation.org/parcels/osaf/contentmodel']
@@ -44,8 +35,6 @@
GenerateItems.GenerateContacts(10)
self.rep.commit()
- import logging
- self.rep.logger.setLevel(logging.DEBUG)
results = self._executeQuery('union(for i in "//parcels/osaf/contentmodel/calendar/CalendarEvent" where True, for i in "//parcels/osaf/contentmodel/Note" where True, for i in "//parcels/osaf/contentmodel/contacts/Contact" where True)')
# these checks could be more robust
# check twice to make sure generator restarts
Index: chandler/repository/query/tests/TestNotification.py
diff -u chandler/repository/query/tests/TestNotification.py:1.4 chandler/repository/query/tests/TestNotification.py:1.5
--- chandler/repository/query/tests/TestNotification.py:1.4 Mon Aug 23 12:42:50 2004
+++ chandler/repository/query/tests/TestNotification.py Wed Sep 1 15:38:10 2004
@@ -1,6 +1,6 @@
-__revision__ = "$Revision: 1.4 $"
-__date__ = "$Date: 2004/08/23 19:42:50 $"
+__revision__ = "$Revision: 1.5 $"
+__date__ = "$Date: 2004/09/01 22:38:10 $"
__copyright__ = "Copyright (c) 2004 Open Source Applications Foundation"
__license__ = "http://osafoundation.org/Chandler_0.1_license_terms.htm"
@@ -12,15 +12,9 @@
def testNotify(self):
""" Test query notification """
- import application
- import application.Globals as Globals
import osaf.contentmodel.tests.GenerateItems as GenerateItems
- from osaf.framework.notifications.NotificationManager import NotificationManager
import osaf.contentmodel.ItemCollection as ItemCollection
- Globals.repository = self.rep
- Globals.notificationManager = NotificationManager()
-
self.loadParcels(
['http://osafoundation.org/parcels/osaf/contentmodel/contacts',
'http://osafoundation.org/parcels/osaf/contentmodel']
Index: chandler/repository/query/tests/TestSimpleQueries.py
diff -u chandler/repository/query/tests/TestSimpleQueries.py:1.8 chandler/repository/query/tests/TestSimpleQueries.py:1.9
--- chandler/repository/query/tests/TestSimpleQueries.py:1.8 Tue Aug 31 12:45:26 2004
+++ chandler/repository/query/tests/TestSimpleQueries.py Wed Sep 1 15:38:10 2004
@@ -1,26 +1,30 @@
-__revision__ = "$Revision: 1.8 $"
-__date__ = "$Date: 2004/08/31 19:45:26 $"
+__revision__ = "$Revision: 1.9 $"
+__date__ = "$Date: 2004/09/01 22:38:10 $"
__copyright__ = "Copyright (c) 2004 Open Source Applications Foundation"
__license__ = "http://osafoundation.org/Chandler_0.1_license_terms.htm"
import os, unittest
import repository.query.tests.QueryTestCase as QueryTestCase
import tools.timing
-import osaf.contentmodel.mail.Mail as Mail
class TestSimpleQueries(QueryTestCase.QueryTestCase):
- """
def testOutBoxQueryWithMail(self):
+ self.loadParcels(
+ ['http://osafoundation.org/parcels/osaf/contentmodel/mail']
+ )
+
+ import osaf.contentmodel.mail.Mail as Mail
# create an outbound Mail item
aMessage = Mail.MailMessage()
+ aMessage.isInbound = True
+ self.rep.commit()
# now run the query
- print "testing with a Mail item"
- qString = u"for i in '//parcels/osaf/contentmodel/mail/MailMessageMixin' where contains(i.isInbound,True)"
+
+ qString = u"for i in '//parcels/osaf/contentmodel/mail/MailMessageMixin' where i.isInbound == True"
results = self._executeQuery(qString)
- self._checkQuery(lambda i: False, results)
- """
+ self._checkQuery(lambda i: not i.isInbound is True, results)
def testKindQuery(self):
""" Test a simulation of kindQuery """
@@ -75,15 +79,7 @@
def testItemTraversalQuery(self):
""" Test a multiple item path traversal in the query predicate """
- tools.timing.reset()
- tools.timing.begin("Setup Infrastructure")
- import application
- import application.Globals as Globals
import osaf.contentmodel.tests.GenerateItems as GenerateItems
- from osaf.framework.notifications.NotificationManager import NotificationManager
- Globals.repository = self.rep
- Globals.notificationManager = NotificationManager()
- tools.timing.end("Setup Infrastructure")
tools.timing.begin("Load Contacts Parcel")
self.loadParcels(
@@ -106,14 +102,7 @@
def testEnumerationQuery(self):
""" Test an enumeration attribute in the query predicate """
tools.timing.reset()
- tools.timing.begin("Setup Infrastructure")
- import application
- import application.Globals as Globals
import osaf.contentmodel.tests.GenerateItems as GenerateItems
- from osaf.framework.notifications.NotificationManager import NotificationManager
- Globals.repository = self.rep
- Globals.notificationManager = NotificationManager()
- tools.timing.end("Setup Infrastructure")
tools.timing.begin("Load Calendar Parcel")
self.loadParcels(
@@ -146,6 +135,16 @@
self._checkQuery(lambda i: not 'ttributes' in i.itsName, q)
+ def testWhereVariableQuery(self):
+ """ Test using a variable in the where clause """
+ queryString= u'for i in "//Schema/Core/Kind" where contains(i.itsName,$0)'
+ import repository.query.Query as Query
+ q = Query.Query(self.rep, queryString)
+ pattern = 'arc'
+ q.args = [ pattern ]
+ q.execute()
+ self._checkQuery(lambda i: not pattern in i.itsName, q)
+
if __name__ == "__main__":
# import hotshot
# profiler = hotshot.Profile('/tmp/TestItems.hotshot')
More information about the Commits
mailing list