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