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