server/test/unittest_migractions.py
changeset 5174 78438ad513ca
parent 4774 89a7555020ba
child 5423 e15abfdcce38
equal deleted inserted replaced
5173:73760bbb66bd 5174:78438ad513ca
   106         self.assertEquals(self.schema['mydate'].subjects(), ('Note', ))
   106         self.assertEquals(self.schema['mydate'].subjects(), ('Note', ))
   107         self.assertEquals(self.schema['mydate'].objects(), ('Date', ))
   107         self.assertEquals(self.schema['mydate'].objects(), ('Date', ))
   108         testdate = date(2005, 12, 13)
   108         testdate = date(2005, 12, 13)
   109         eid1 = self.mh.rqlexec('INSERT Note N')[0][0]
   109         eid1 = self.mh.rqlexec('INSERT Note N')[0][0]
   110         eid2 = self.mh.rqlexec('INSERT Note N: N mydate %(mydate)s', {'mydate' : testdate})[0][0]
   110         eid2 = self.mh.rqlexec('INSERT Note N: N mydate %(mydate)s', {'mydate' : testdate})[0][0]
   111         d1 = self.mh.rqlexec('Any D WHERE X eid %(x)s, X mydate D', {'x': eid1}, 'x')[0][0]
   111         d1 = self.mh.rqlexec('Any D WHERE X eid %(x)s, X mydate D', {'x': eid1})[0][0]
   112         d2 = self.mh.rqlexec('Any D WHERE X eid %(x)s, X mydate D', {'x': eid2}, 'x')[0][0]
   112         d2 = self.mh.rqlexec('Any D WHERE X eid %(x)s, X mydate D', {'x': eid2})[0][0]
   113         self.assertEquals(d1, date.today())
   113         self.assertEquals(d1, date.today())
   114         self.assertEquals(d2, testdate)
   114         self.assertEquals(d2, testdate)
   115         self.mh.rollback()
   115         self.mh.rollback()
   116 
   116 
   117     def test_rename_attribute(self):
   117     def test_rename_attribute(self):
   501         # test columns have been actually added
   501         # test columns have been actually added
   502         text = self.execute('INSERT Text X: X para "hip", X summary "hop", X newattr "momo"').get_entity(0, 0)
   502         text = self.execute('INSERT Text X: X para "hip", X summary "hop", X newattr "momo"').get_entity(0, 0)
   503         note = self.execute('INSERT Note X: X para "hip", X shortpara "hop", X newattr "momo"').get_entity(0, 0)
   503         note = self.execute('INSERT Note X: X para "hip", X shortpara "hop", X newattr "momo"').get_entity(0, 0)
   504         aff = self.execute('INSERT Affaire X').get_entity(0, 0)
   504         aff = self.execute('INSERT Affaire X').get_entity(0, 0)
   505         self.failUnless(self.execute('SET X newnotinlined Y WHERE X eid %(x)s, Y eid %(y)s',
   505         self.failUnless(self.execute('SET X newnotinlined Y WHERE X eid %(x)s, Y eid %(y)s',
   506                                      {'x': text.eid, 'y': aff.eid}, 'x'))
   506                                      {'x': text.eid, 'y': aff.eid}))
   507         self.failUnless(self.execute('SET X newnotinlined Y WHERE X eid %(x)s, Y eid %(y)s',
   507         self.failUnless(self.execute('SET X newnotinlined Y WHERE X eid %(x)s, Y eid %(y)s',
   508                                      {'x': note.eid, 'y': aff.eid}, 'x'))
   508                                      {'x': note.eid, 'y': aff.eid}))
   509         self.failUnless(self.execute('SET X newinlined Y WHERE X eid %(x)s, Y eid %(y)s',
   509         self.failUnless(self.execute('SET X newinlined Y WHERE X eid %(x)s, Y eid %(y)s',
   510                                      {'x': text.eid, 'y': aff.eid}, 'x'))
   510                                      {'x': text.eid, 'y': aff.eid}))
   511         self.failUnless(self.execute('SET X newinlined Y WHERE X eid %(x)s, Y eid %(y)s',
   511         self.failUnless(self.execute('SET X newinlined Y WHERE X eid %(x)s, Y eid %(y)s',
   512                                      {'x': note.eid, 'y': aff.eid}, 'x'))
   512                                      {'x': note.eid, 'y': aff.eid}))
   513         # XXX remove specializes by ourselves, else tearDown fails when removing
   513         # XXX remove specializes by ourselves, else tearDown fails when removing
   514         # Para because of Note inheritance. This could be fixed by putting the
   514         # Para because of Note inheritance. This could be fixed by putting the
   515         # MemSchemaCWETypeDel(session, name) operation in the
   515         # MemSchemaCWETypeDel(session, name) operation in the
   516         # after_delete_entity(CWEType) hook, since in that case the MemSchemaSpecializesDel
   516         # after_delete_entity(CWEType) hook, since in that case the MemSchemaSpecializesDel
   517         # operation would be removed before, but I'm not sure this is a desired behaviour.
   517         # operation would be removed before, but I'm not sure this is a desired behaviour.