server/test/unittest_migractions.py
branchstable
changeset 3543 ed152fe5aa8b
parent 3316 c4c07aab1c39
child 3587 5b3725f315fc
equal deleted inserted replaced
3542:4c92cd09882f 3543:ed152fe5aa8b
    46         assert self.session is self.mh.session, (self.session.id, self.mh.session.id)
    46         assert self.session is self.mh.session, (self.session.id, self.mh.session.id)
    47 
    47 
    48 
    48 
    49     def test_add_attribute_int(self):
    49     def test_add_attribute_int(self):
    50         self.failIf('whatever' in self.schema)
    50         self.failIf('whatever' in self.schema)
       
    51         self.add_entity('Note')
       
    52         self.commit()
    51         orderdict = dict(self.mh.rqlexec('Any RTN, O WHERE X name "Note", RDEF from_entity X, '
    53         orderdict = dict(self.mh.rqlexec('Any RTN, O WHERE X name "Note", RDEF from_entity X, '
    52                                          'RDEF relation_type RT, RDEF ordernum O, RT name RTN'))
    54                                          'RDEF relation_type RT, RDEF ordernum O, RT name RTN'))
    53         self.mh.cmd_add_attribute('Note', 'whatever')
    55         self.mh.cmd_add_attribute('Note', 'whatever')
    54         self.failUnless('whatever' in self.schema)
    56         self.failUnless('whatever' in self.schema)
    55         self.assertEquals(self.schema['whatever'].subjects(), ('Note',))
    57         self.assertEquals(self.schema['whatever'].subjects(), ('Note',))
    56         self.assertEquals(self.schema['whatever'].objects(), ('Int',))
    58         self.assertEquals(self.schema['whatever'].objects(), ('Int',))
       
    59         self.assertEquals(self.schema['Note'].default('whatever'), 2)
       
    60         note = self.execute('Note X').get_entity(0, 0)
       
    61         self.assertEquals(note.whatever, 2)
    57         orderdict2 = dict(self.mh.rqlexec('Any RTN, O WHERE X name "Note", RDEF from_entity X, '
    62         orderdict2 = dict(self.mh.rqlexec('Any RTN, O WHERE X name "Note", RDEF from_entity X, '
    58                                           'RDEF relation_type RT, RDEF ordernum O, RT name RTN'))
    63                                           'RDEF relation_type RT, RDEF ordernum O, RT name RTN'))
    59         whateverorder = migrschema['whatever'].rproperty('Note', 'Int', 'order')
    64         whateverorder = migrschema['whatever'].rproperty('Note', 'Int', 'order')
    60         for k, v in orderdict.iteritems():
    65         for k, v in orderdict.iteritems():
    61             if v >= whateverorder:
    66             if v >= whateverorder: