common/test/unittest_migration.py
branchtls-sprint
changeset 1802 d628defebc17
parent 755 cf75a7dbd99a
child 1977 606923dff11b
equal deleted inserted replaced
1801:672acc730ce5 1802:d628defebc17
    22     def migration_scripts_dir(cls):
    22     def migration_scripts_dir(cls):
    23         return SMIGRDIR
    23         return SMIGRDIR
    24 
    24 
    25     def cube_migration_scripts_dir(cls, cube):
    25     def cube_migration_scripts_dir(cls, cube):
    26         return TMIGRDIR
    26         return TMIGRDIR
    27     
    27 
    28 class MigrationToolsTC(TestCase):
    28 class MigrationToolsTC(TestCase):
    29     def setUp(self):
    29     def setUp(self):
    30         self.config = MigrTestConfig('data')
    30         self.config = MigrTestConfig('data')
    31         from yams.schema import Schema
    31         from yams.schema import Schema
    32         self.config.load_schema = lambda expand_cubes=False: Schema('test')
    32         self.config.load_schema = lambda expand_cubes=False: Schema('test')
    33         self.config.__class__.cubicweb_vobject_path = frozenset()
    33         self.config.__class__.cubicweb_vobject_path = frozenset()
    34         self.config.__class__.cube_vobject_path = frozenset()
    34         self.config.__class__.cube_vobject_path = frozenset()
    35         
    35 
    36     def test_migration_files_base(self):
    36     def test_migration_files_base(self):
    37         self.assertListEquals(migration_files(self.config, [('cubicweb', (2,3,0), (2,4,0)),
    37         self.assertListEquals(migration_files(self.config, [('cubicweb', (2,3,0), (2,4,0)),
    38                                                             ('TEMPLATE', (0,0,2), (0,0,3))]),
    38                                                             ('TEMPLATE', (0,0,2), (0,0,3))]),
    39                               [SMIGRDIR+'bootstrapmigration_repository.py',
    39                               [SMIGRDIR+'bootstrapmigration_repository.py',
    40                                TMIGRDIR+'0.0.3_Any.py'])
    40                                TMIGRDIR+'0.0.3_Any.py'])
    46         self.assertListEquals(migration_files(self.config, [('cubicweb', (2,5,0), (2,6,0)),
    46         self.assertListEquals(migration_files(self.config, [('cubicweb', (2,5,0), (2,6,0)),
    47                                                             ('TEMPLATE', (0,0,3), (0,0,4))]),
    47                                                             ('TEMPLATE', (0,0,3), (0,0,4))]),
    48                               [SMIGRDIR+'bootstrapmigration_repository.py',
    48                               [SMIGRDIR+'bootstrapmigration_repository.py',
    49                                SMIGRDIR+'2.6.0_Any.sql',
    49                                SMIGRDIR+'2.6.0_Any.sql',
    50                                TMIGRDIR+'0.0.4_Any.py'])
    50                                TMIGRDIR+'0.0.4_Any.py'])
    51         
    51 
    52 ##     def test_migration_files_overlap(self):
    52 ##     def test_migration_files_overlap(self):
    53 ##         self.assertListEquals(migration_files(self.config, (2,4,0), (2,10,2),
    53 ##         self.assertListEquals(migration_files(self.config, (2,4,0), (2,10,2),
    54 ##                                               (0,0,2), (0,1,2)),
    54 ##                                               (0,0,2), (0,1,2)),
    55 ##                               [SMIGRDIR+'bootstrapmigration_repository.py',
    55 ##                               [SMIGRDIR+'bootstrapmigration_repository.py',
    56 ##                                TMIGRDIR+'0.0.3_Any.py',
    56 ##                                TMIGRDIR+'0.0.3_Any.py',
    60 ##                                TMIGRDIR+'0.1.0_Any.py',
    60 ##                                TMIGRDIR+'0.1.0_Any.py',
    61 ##                                TMIGRDIR+'0.1.0_common.py',
    61 ##                                TMIGRDIR+'0.1.0_common.py',
    62 ##                                TMIGRDIR+'0.1.0_repository.py',
    62 ##                                TMIGRDIR+'0.1.0_repository.py',
    63 ##                                TMIGRDIR+'0.1.2_Any.py',
    63 ##                                TMIGRDIR+'0.1.2_Any.py',
    64 ##                                SMIGRDIR+'2.10.1_2.10.2_Any.sql'])
    64 ##                                SMIGRDIR+'2.10.1_2.10.2_Any.sql'])
    65         
    65 
    66     def test_migration_files_for_mode(self):
    66     def test_migration_files_for_mode(self):
    67         from cubicweb.server.migractions import ServerMigrationHelper
    67         from cubicweb.server.migractions import ServerMigrationHelper
    68         self.assertIsInstance(self.config.migration_handler(), ServerMigrationHelper)
    68         self.assertIsInstance(self.config.migration_handler(), ServerMigrationHelper)
    69         from cubicweb.common.migration import MigrationHelper
    69         from cubicweb.common.migration import MigrationHelper
    70         config = CubicWebConfiguration('data')
    70         config = CubicWebConfiguration('data')