server/test/unittest_migractions.py
brancholdstable
changeset 7078 bad26a22fe29
parent 7073 4ce9e536dd66
child 7242 7c1937215db9
equal deleted inserted replaced
7074:e4580e5f0703 7078:bad26a22fe29
    43 class MigrationCommandsTC(CubicWebTC):
    43 class MigrationCommandsTC(CubicWebTC):
    44 
    44 
    45     tags = CubicWebTC.tags | Tags(('server', 'migration', 'migractions'))
    45     tags = CubicWebTC.tags | Tags(('server', 'migration', 'migractions'))
    46 
    46 
    47     @classmethod
    47     @classmethod
    48     def init_config(cls, config):
    48     def _init_repo(cls):
    49         super(MigrationCommandsTC, cls).init_config(config)
    49         super(MigrationCommandsTC, cls)._init_repo()
    50         # 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
       
    51         config = cls.config
    51         config._cubes = None
    52         config._cubes = None
    52         cls.repo.fill_schema()
    53         cls.repo.fill_schema()
    53         cls.origschema = deepcopy(cls.repo.schema)
    54         cls.origschema = deepcopy(cls.repo.schema)
    54         # hack to read the schema from data/migrschema
    55         # hack to read the schema from data/migrschema
    55         config.appid = join('data', 'migratedapp')
    56         config.appid = join('data', 'migratedapp')
    57         global migrschema
    58         global migrschema
    58         migrschema = config.load_schema()
    59         migrschema = config.load_schema()
    59         config.appid = 'data'
    60         config.appid = 'data'
    60         config._apphome = cls.datadir
    61         config._apphome = cls.datadir
    61         assert 'Folder' in migrschema
    62         assert 'Folder' in migrschema
    62 
       
    63     @classmethod
       
    64     def _refresh_repo(cls):
       
    65         super(MigrationCommandsTC, cls)._refresh_repo()
       
    66         cls.repo.set_schema(deepcopy(cls.origschema), resetvreg=False)
       
    67         # reset migration schema eids
       
    68         for eschema in migrschema.entities():
       
    69             eschema.eid = None
       
    70         for rschema in migrschema.relations():
       
    71             rschema.eid = None
       
    72             for rdef in rschema.rdefs.values():
       
    73                 rdef.eid = None
       
    74 
    63 
    75     def setUp(self):
    64     def setUp(self):
    76         CubicWebTC.setUp(self)
    65         CubicWebTC.setUp(self)
    77         self.mh = ServerMigrationHelper(self.repo.config, migrschema,
    66         self.mh = ServerMigrationHelper(self.repo.config, migrschema,
    78                                         repo=self.repo, cnx=self.cnx,
    67                                         repo=self.repo, cnx=self.cnx,