equal
deleted
inserted
replaced
21 |
21 |
22 from copy import deepcopy |
22 from copy import deepcopy |
23 from datetime import date |
23 from datetime import date |
24 from os.path import join |
24 from os.path import join |
25 |
25 |
26 from logilab.common.testlib import TestCase, unittest_main |
26 from logilab.common.testlib import TestCase, unittest_main, Tags, tag |
27 |
27 |
28 from yams.constraints import UniqueConstraint |
28 from yams.constraints import UniqueConstraint |
29 |
29 |
30 from cubicweb import ConfigurationError, ValidationError |
30 from cubicweb import ConfigurationError, ValidationError |
31 from cubicweb.devtools.testlib import CubicWebTC |
31 from cubicweb.devtools.testlib import CubicWebTC |
35 |
35 |
36 migrschema = None |
36 migrschema = None |
37 def tearDownModule(*args): |
37 def tearDownModule(*args): |
38 global migrschema |
38 global migrschema |
39 del migrschema |
39 del migrschema |
40 del MigrationCommandsTC.origschema |
40 if hasattr(MigrationCommandsTC, 'origschema'): |
|
41 del MigrationCommandsTC.origschema |
41 |
42 |
42 class MigrationCommandsTC(CubicWebTC): |
43 class MigrationCommandsTC(CubicWebTC): |
|
44 |
|
45 tags = CubicWebTC.tags | Tags(('server', 'migration', 'migractions')) |
43 |
46 |
44 @classmethod |
47 @classmethod |
45 def init_config(cls, config): |
48 def init_config(cls, config): |
46 super(MigrationCommandsTC, cls).init_config(config) |
49 super(MigrationCommandsTC, cls).init_config(config) |
47 # we have to read schema from the database to get eid for schema entities |
50 # we have to read schema from the database to get eid for schema entities |
341 self.assertEqual(card, True) |
344 self.assertEqual(card, True) |
342 finally: |
345 finally: |
343 self.mh.cmd_change_relation_props('Personne', 'adel', 'String', |
346 self.mh.cmd_change_relation_props('Personne', 'adel', 'String', |
344 fulltextindexed=False) |
347 fulltextindexed=False) |
345 |
348 |
|
349 @tag('longrun') |
346 def test_sync_schema_props_perms(self): |
350 def test_sync_schema_props_perms(self): |
347 cursor = self.mh.session |
351 cursor = self.mh.session |
348 cursor.set_pool() |
352 cursor.set_pool() |
349 nbrqlexpr_start = cursor.execute('Any COUNT(X) WHERE X is RQLExpression')[0][0] |
353 nbrqlexpr_start = cursor.execute('Any COUNT(X) WHERE X is RQLExpression')[0][0] |
350 migrschema['titre'].rdefs[('Personne', 'String')].order = 7 |
354 migrschema['titre'].rdefs[('Personne', 'String')].order = 7 |
462 try: |
466 try: |
463 self.mh.cmd_set_size_constraint('CWEType', 'description', 256) |
467 self.mh.cmd_set_size_constraint('CWEType', 'description', 256) |
464 finally: |
468 finally: |
465 self.mh.cmd_set_size_constraint('CWEType', 'description', None) |
469 self.mh.cmd_set_size_constraint('CWEType', 'description', None) |
466 |
470 |
|
471 @tag('longrun') |
467 def test_add_remove_cube_and_deps(self): |
472 def test_add_remove_cube_and_deps(self): |
468 cubes = set(self.config.cubes()) |
473 cubes = set(self.config.cubes()) |
469 schema = self.repo.schema |
474 schema = self.repo.schema |
470 self.assertEqual(sorted((str(s), str(o)) for s, o in schema['see_also'].rdefs.keys()), |
475 self.assertEqual(sorted((str(s), str(o)) for s, o in schema['see_also'].rdefs.keys()), |
471 sorted([('EmailThread', 'EmailThread'), ('Folder', 'Folder'), |
476 sorted([('EmailThread', 'EmailThread'), ('Folder', 'Folder'), |
525 # why this commit is necessary is unclear to me (though without it |
530 # why this commit is necessary is unclear to me (though without it |
526 # next test may fail complaining of missing tables |
531 # next test may fail complaining of missing tables |
527 self.commit() |
532 self.commit() |
528 |
533 |
529 |
534 |
|
535 @tag('longrun') |
530 def test_add_remove_cube_no_deps(self): |
536 def test_add_remove_cube_no_deps(self): |
531 cubes = set(self.config.cubes()) |
537 cubes = set(self.config.cubes()) |
532 schema = self.repo.schema |
538 schema = self.repo.schema |
533 try: |
539 try: |
534 try: |
540 try: |
556 def test_remove_dep_cube(self): |
562 def test_remove_dep_cube(self): |
557 with self.assertRaises(ConfigurationError) as cm: |
563 with self.assertRaises(ConfigurationError) as cm: |
558 self.mh.cmd_remove_cube('file') |
564 self.mh.cmd_remove_cube('file') |
559 self.assertEqual(str(cm.exception), "can't remove cube file, used as a dependency") |
565 self.assertEqual(str(cm.exception), "can't remove cube file, used as a dependency") |
560 |
566 |
|
567 @tag('longrun') |
561 def test_introduce_base_class(self): |
568 def test_introduce_base_class(self): |
562 self.mh.cmd_add_entity_type('Para') |
569 self.mh.cmd_add_entity_type('Para') |
563 self.mh.repo.schema.rebuild_infered_relations() |
570 self.mh.repo.schema.rebuild_infered_relations() |
564 self.assertEqual(sorted(et.type for et in self.schema['Para'].specialized_by()), |
571 self.assertEqual(sorted(et.type for et in self.schema['Para'].specialized_by()), |
565 ['Note']) |
572 ['Note']) |