[Checkins] SVN: Sandbox/adamg/ocql/branches/dbprovider/src/ocql/ clean the code by removing print statements, debugger codes and add aditional tests

Charith Paranaliyanage paranaliyanage at gmail.com
Tue Jun 24 23:23:36 EDT 2008


Log message for revision 87741:
  clean the code by removing print statements, debugger codes and add aditional tests

Changed:
  U   Sandbox/adamg/ocql/branches/dbprovider/src/ocql/database/metadata.py
  D   Sandbox/adamg/ocql/branches/dbprovider/src/ocql/testing/gsocdatabase.py
  U   Sandbox/adamg/ocql/branches/dbprovider/src/ocql/testing/utils.py
  U   Sandbox/adamg/ocql/branches/dbprovider/src/ocql/tests/test_zope.py

-=-
Modified: Sandbox/adamg/ocql/branches/dbprovider/src/ocql/database/metadata.py
===================================================================
--- Sandbox/adamg/ocql/branches/dbprovider/src/ocql/database/metadata.py	2008-06-25 02:05:41 UTC (rev 87740)
+++ Sandbox/adamg/ocql/branches/dbprovider/src/ocql/database/metadata.py	2008-06-25 03:23:35 UTC (rev 87741)
@@ -69,11 +69,10 @@
         #items = list(searchInterfaceUtilities(self))
         catalogs = getUtilitiesFor(ICatalog)
         intids = getUtility(IIntIds)
-        for i in catalogs:
-            catalog = i[1]
+        for name, catalog in catalogs:
             for index in catalog:
-                if isinstance(catalog[index], AllIndex):
-                    interface =  catalog[index].interface
+                if isinstance(catalog[index], AllIndex):                    
+                    interface = catalog[index].interface
                     results = catalog.apply({index:(1,1)})
                     obj_list = []
                     for result in results:
@@ -82,10 +81,6 @@
                     self.db.__setitem__(interface.__name__,obj_list)
                     self.classes.__setitem__(interface.__name__,MClass(interface))
         
-        #seems db and classes are correctly filled
-        #print self.db
-        #print self.classes
-        
 
     def getAll(self, klass):
         return self.db[klass]

Deleted: Sandbox/adamg/ocql/branches/dbprovider/src/ocql/testing/gsocdatabase.py
===================================================================
--- Sandbox/adamg/ocql/branches/dbprovider/src/ocql/testing/gsocdatabase.py	2008-06-25 02:05:41 UTC (rev 87740)
+++ Sandbox/adamg/ocql/branches/dbprovider/src/ocql/testing/gsocdatabase.py	2008-06-25 03:23:35 UTC (rev 87741)
@@ -1,28 +0,0 @@
-
-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

Modified: Sandbox/adamg/ocql/branches/dbprovider/src/ocql/testing/utils.py
===================================================================
--- Sandbox/adamg/ocql/branches/dbprovider/src/ocql/testing/utils.py	2008-06-25 02:05:41 UTC (rev 87740)
+++ Sandbox/adamg/ocql/branches/dbprovider/src/ocql/testing/utils.py	2008-06-25 03:23:35 UTC (rev 87741)
@@ -62,7 +62,7 @@
 
     p1 = Project()
     p1.name = u"Save the world"
-    p1.description = u""
+    p1.description = u"test"
     id = intids.register(p1)
     cat.index_doc(id, p1)
 

Modified: Sandbox/adamg/ocql/branches/dbprovider/src/ocql/tests/test_zope.py
===================================================================
--- Sandbox/adamg/ocql/branches/dbprovider/src/ocql/tests/test_zope.py	2008-06-25 02:05:41 UTC (rev 87740)
+++ Sandbox/adamg/ocql/branches/dbprovider/src/ocql/tests/test_zope.py	2008-06-25 03:23:35 UTC (rev 87741)
@@ -18,11 +18,8 @@
 from ocql.testing.utils import setupInterfaces, setupCatalog
 from ocql.tests.test_old import QueryNullParser
 from ocql.testing.sample.student import Student
-#REMOVE THIS LATER
-from ocql.testing.sample.interfaces import IOrganization, IStudent, IMentor, IProject
 
 
-
 db = {}
 
 classes = {}
@@ -90,7 +87,7 @@
         #
         # Simple SELECT ALL
         #
-        # set [ c in ICourse | c ]
+        # set [ c in IStudent | c ]
         #           
         query = "[c in IStudent | c]"
         qo = Query(
@@ -106,7 +103,49 @@
         self.doit(query, qo, set(metadata.db['IStudent']))
         
         
+        symbols = SymbolContainer()
+        #
+        # Selecting a property
+        #
+        # set [ c in IStudent | c.name ]
+        #
+        query = "[c in IStudent | c.name]"
+        qo = Query(
+                   metadata, symbols,
+                   set,
+                   [
+                        In(
+                           metadata, symbols,
+                           Identifier(metadata, symbols,'c'),
+                           Identifier(metadata, symbols, 'IStudent'))
+                    ],Identifier(metadata, symbols, 'c.name'))
+        self.doit(query, qo, set(["Charith", "Jane", "Ann"]))                   
         
+        
+        symbols = SymbolContainer()
+        #
+        # Filtering --one result
+        #
+        # set [ c in IProject , c.description="test" | c.name]
+        #
+        query = "[c in IProject , c.description=test | c.name]"
+        qo = Query(
+                   metadata, symbols,
+                   set,
+                   [
+                        In(
+                           metadata, symbols,
+                           Identifier(metadata,symbols,'c'),
+                           Identifier(metadata,symbols, 'IProject')),
+                        Eq(
+                           metadata,symbols,
+                           Identifier(metadata, symbols, 'c.description'),
+                           Identifier(metadata, symbols, '"test"'))
+                   ], Identifier(metadata, symbols, 'c.name'))
+                   
+        self.doit(query, qo, set(["Save the world"]))
+        
+        
 def test_suite():
     flags =  doctest.NORMALIZE_WHITESPACE|doctest.ELLIPSIS
     return unittest.TestSuite((



More information about the Checkins mailing list