447 user = self.session.user |
447 user = self.session.user |
448 self.mh.set_state(user.eid, 'deactivated') |
448 self.mh.set_state(user.eid, 'deactivated') |
449 user.clear_related_cache('in_state', 'subject') |
449 user.clear_related_cache('in_state', 'subject') |
450 self.assertEquals(user.state, 'deactivated') |
450 self.assertEquals(user.state, 'deactivated') |
451 |
451 |
|
452 def test_introduce_base_class(self): |
|
453 self.mh.cmd_add_entity_type('Para') |
|
454 self.mh.repo.schema.rebuild_infered_relations() |
|
455 self.assertEquals(sorted(et.type for et in self.schema['Para'].specialized_by()), |
|
456 ['Note']) |
|
457 self.assertEquals(self.schema['Note'].specializes().type, 'Para') |
|
458 self.mh.cmd_add_entity_type('Text') |
|
459 self.mh.repo.schema.rebuild_infered_relations() |
|
460 self.assertEquals(sorted(et.type for et in self.schema['Para'].specialized_by()), |
|
461 ['Note', 'Text']) |
|
462 self.assertEquals(self.schema['Text'].specializes().type, 'Para') |
|
463 # test columns have been actually added |
|
464 text = self.execute('INSERT Text X: X para "hip", X summary "hop", X newattr "momo"').get_entity(0, 0) |
|
465 note = self.execute('INSERT Note X: X para "hip", X shortpara "hop", X newattr "momo"').get_entity(0, 0) |
|
466 aff = self.execute('INSERT Affaire X').get_entity(0, 0) |
|
467 self.failUnless(self.execute('SET X newnotinlined Y WHERE X eid %(x)s, Y eid %(y)s', |
|
468 {'x': text.eid, 'y': aff.eid}, 'x')) |
|
469 self.failUnless(self.execute('SET X newnotinlined Y WHERE X eid %(x)s, Y eid %(y)s', |
|
470 {'x': note.eid, 'y': aff.eid}, 'x')) |
|
471 self.failUnless(self.execute('SET X newinlined Y WHERE X eid %(x)s, Y eid %(y)s', |
|
472 {'x': text.eid, 'y': aff.eid}, 'x')) |
|
473 self.failUnless(self.execute('SET X newinlined Y WHERE X eid %(x)s, Y eid %(y)s', |
|
474 {'x': note.eid, 'y': aff.eid}, 'x')) |
|
475 # XXX remove specializes by ourselves, else tearDown fails when removing |
|
476 # Para because of Note inheritance. This could be fixed by putting the |
|
477 # MemSchemaCWETypeDel(session, name) operation in the |
|
478 # after_delete_entity(CWEType) hook, since in that case the MemSchemaSpecializesDel |
|
479 # operation would be removed before, but I'm not sure this is a desired behaviour. |
|
480 # |
|
481 # also we need more tests about introducing/removing base classes or |
|
482 # specialization relationship... |
|
483 self.session.data['rebuild-infered'] = True |
|
484 try: |
|
485 self.execute('DELETE X specializes Y WHERE Y name "Para"') |
|
486 self.commit() |
|
487 finally: |
|
488 self.session.data['rebuild-infered'] = False |
|
489 self.assertEquals(sorted(et.type for et in self.schema['Para'].specialized_by()), |
|
490 []) |
|
491 self.assertEquals(self.schema['Note'].specializes(), None) |
|
492 self.assertEquals(self.schema['Text'].specializes(), None) |
|
493 |
452 if __name__ == '__main__': |
494 if __name__ == '__main__': |
453 unittest_main() |
495 unittest_main() |