[Checkins]
SVN: Sandbox/adamg/ocql/branches/dbprovider/src/ocql/test
upload test class to simulate the zope using the gsoc
compitition example
Charith Paranaliyanage
paranaliyanage at gmail.com
Thu Jun 19 10:09:09 EDT 2008
Log message for revision 87552:
upload test class to simulate the zope using the gsoc compitition example
Changed:
A Sandbox/adamg/ocql/branches/dbprovider/src/ocql/testing/gsocdatabase.py
A Sandbox/adamg/ocql/branches/dbprovider/src/ocql/tests/test_zope.py
-=-
Added: Sandbox/adamg/ocql/branches/dbprovider/src/ocql/testing/gsocdatabase.py
===================================================================
--- Sandbox/adamg/ocql/branches/dbprovider/src/ocql/testing/gsocdatabase.py (rev 0)
+++ Sandbox/adamg/ocql/branches/dbprovider/src/ocql/testing/gsocdatabase.py 2008-06-19 14:09:09 UTC (rev 87552)
@@ -0,0 +1,28 @@
+
+from ocql.database import metadata
+from zope.interface import implements
+from zope.component import adapts
+from ocql.interfaces import IDB
+import ocql.tests.test_zope
+
+class GsocMetadata(metadata.Metadata):
+ implements(IDB)
+ adapts(None)
+
+ db = {
+ }
+
+ classes = {
+ }
+
+ def __init__(self, context=None):
+ import pydevd;pydevd.settrace()
+ db = ocql.tests.test_zope.db
+ classes = ocql.tests.test_zope.classes
+
+ def getAll(self, klass):
+ x=self.db[klass]
+ return x
+
+ def get_class(self, name):
+ return self.classes[name]
\ No newline at end of file
Added: Sandbox/adamg/ocql/branches/dbprovider/src/ocql/tests/test_zope.py
===================================================================
--- Sandbox/adamg/ocql/branches/dbprovider/src/ocql/tests/test_zope.py (rev 0)
+++ Sandbox/adamg/ocql/branches/dbprovider/src/ocql/tests/test_zope.py 2008-06-19 14:09:09 UTC (rev 87552)
@@ -0,0 +1,81 @@
+import unittest
+import doctest
+from zope.component.interface import searchInterfaceUtilities
+from zope.interface import implements
+from zope.component import adapts, getUtility, provideAdapter
+from ocql.interfaces import IDB
+from ocql.database import metadata
+from zope.interface import Interface
+from zope.app.catalog.interfaces import ICatalog
+from ocql.testing.utils import setupInterfaces, setupCatalog
+from zope.location import LocationProxy
+from zope.app.intid import IIntIds
+from ocql.parser.queryparser import QueryParser, SymbolContainer
+from ocql.tests.test_old import QueryNullParser
+from ocql.qoptimizer.qoptimizer import QueryOptimizer
+from ocql.rewriter.rewriter import Rewriter
+from ocql.aoptimizer.aoptimizer import AlgebraOptimizer
+from ocql.compiler.compiler import AlgebraCompiler
+from ocql.testing.gsocdatabase import GsocMetadata
+from ocql.testing.sample.student import Student
+
+db = {}
+
+classes = {}
+
+class testZope(unittest.TestCase):
+ def setUp(self):
+ provideAdapter(QueryParser)
+ provideAdapter(QueryNullParser)
+ provideAdapter(QueryOptimizer)
+ provideAdapter(Rewriter)
+ provideAdapter(AlgebraOptimizer)
+ provideAdapter(AlgebraCompiler)
+
+ setupInterfaces(self)
+ setupCatalog(self)
+ #import pydevd;pydevd.settrace()
+ items = list(searchInterfaceUtilities(self))
+ catalog = getUtility(ICatalog,name='foo-catalog')
+
+ intids = getUtility(IIntIds)
+ #is there is a way to find all the indexes
+ results = catalog.apply({'student_name':('A','Z')})
+
+ student_list = []
+ for r in results:
+ obj = intids.getObject(r)
+ print obj.__class__.__name__
+ student_list.append(obj)
+
+ db.__setitem__('student_name', student_list)
+
+ for item in items:
+ print item
+ class_name = item[0].rsplit('.',1)[1].__str__()
+ classes.__setitem__(class_name,class_name)
+ # print item[1].__class__
+
+ GsocMetadata()
+ provideAdapter(GsocMetadata)
+
+
+ def test_gsoc(self):
+ print "loading..."
+ metadata = IDB(None)
+ symbols = SymbolContainer()
+
+
+
+
+
+def test_suite():
+ flags = doctest.NORMALIZE_WHITESPACE|doctest.ELLIPSIS
+ return unittest.TestSuite((
+ unittest.makeSuite(testZope),
+ ))
+
+if __name__ == '__main__':
+ unittest.main(defaultTest='test_suite')
+
+
More information about the Checkins
mailing list