server/test/unittest_repository.py
changeset 1251 af40e615dc89
parent 17 62ce3e6126e0
child 1263 01152fffd593
equal deleted inserted replaced
1250:5c20a7f13c84 1251:af40e615dc89
     6 import threading
     6 import threading
     7 import time
     7 import time
     8 from copy import deepcopy
     8 from copy import deepcopy
     9 
     9 
    10 from mx.DateTime import DateTimeType, now
    10 from mx.DateTime import DateTimeType, now
       
    11 
    11 from logilab.common.testlib import TestCase, unittest_main
    12 from logilab.common.testlib import TestCase, unittest_main
    12 from cubicweb.devtools.apptest import RepositoryBasedTC
       
    13 from cubicweb.devtools.repotest import tuplify
       
    14 
    13 
    15 from yams.constraints import UniqueConstraint
    14 from yams.constraints import UniqueConstraint
    16 
    15 
    17 from cubicweb import BadConnectionId, RepositoryError, ValidationError, UnknownEid, AuthenticationError
    16 from cubicweb import BadConnectionId, RepositoryError, ValidationError, UnknownEid, AuthenticationError
    18 from cubicweb.schema import CubicWebSchema, RQLConstraint
    17 from cubicweb.schema import CubicWebSchema, RQLConstraint
    19 from cubicweb.dbapi import connect, repo_connect
    18 from cubicweb.dbapi import connect, repo_connect
    20 
    19 from cubicweb.devtools.apptest import RepositoryBasedTC
       
    20 from cubicweb.devtools.repotest import tuplify
    21 from cubicweb.server import repository 
    21 from cubicweb.server import repository 
       
    22 from cubicweb.server.sqlutils import SQL_PREFIX
    22 
    23 
    23 
    24 
    24 # start name server anyway, process will fail if already running
    25 # start name server anyway, process will fail if already running
    25 os.system('pyro-ns >/dev/null 2>/dev/null &')
    26 os.system('pyro-ns >/dev/null 2>/dev/null &')
    26 
    27 
    44     def test_fill_schema(self):
    45     def test_fill_schema(self):
    45         self.repo.schema = CubicWebSchema(self.repo.config.appid)
    46         self.repo.schema = CubicWebSchema(self.repo.config.appid)
    46         self.repo.config._cubes = None # avoid assertion error
    47         self.repo.config._cubes = None # avoid assertion error
    47         self.repo.fill_schema()
    48         self.repo.fill_schema()
    48         pool = self.repo._get_pool()
    49         pool = self.repo._get_pool()
       
    50         table = SQL_PREFIX + 'EEType'
       
    51         namecol = SQL_PREFIX + 'name'
       
    52         finalcol = SQL_PREFIX + 'final'
    49         try:
    53         try:
    50             sqlcursor = pool['system']
    54             sqlcursor = pool['system']
    51             sqlcursor.execute('SELECT name FROM EEType WHERE final is NULL')
    55             sqlcursor.execute('SELECT %s FROM %s WHERE %s is NULL' % (
       
    56                 namecol, table, finalcol))
    52             self.assertEquals(sqlcursor.fetchall(), [])
    57             self.assertEquals(sqlcursor.fetchall(), [])
    53             sqlcursor.execute('SELECT name FROM EEType WHERE final=%(final)s ORDER BY name', {'final': 'TRUE'})
    58             sqlcursor.execute('SELECT %s FROM %s WHERE %s=%%(final)s ORDER BY %s'
       
    59                               % (namecol, table, finalcol, namecol), {'final': 'TRUE'})
    54             self.assertEquals(sqlcursor.fetchall(), [(u'Boolean',), (u'Bytes',),
    60             self.assertEquals(sqlcursor.fetchall(), [(u'Boolean',), (u'Bytes',),
    55                                                      (u'Date',), (u'Datetime',),
    61                                                      (u'Date',), (u'Datetime',),
    56                                                      (u'Decimal',),(u'Float',),
    62                                                      (u'Decimal',),(u'Float',),
    57                                                      (u'Int',),
    63                                                      (u'Int',),
    58                                                      (u'Interval',), (u'Password',),
    64                                                      (u'Interval',), (u'Password',),