Exemplo n.º 1
0
    def test_check_field_constraints(self):
        # This test case asserts that a migration from db ver 32 up to 34 with
        # fields that fail the constraints still functions.
        self._initStartDB(32)

        field_dict = helpers.get_dummy_field()
        field_dict['instance'] = 'reference'
        field_dict['step_id'] = None
        field_dict['field_id'] = None

        db_create_field(self.store, field_dict, u'en')

        field_dict = helpers.get_dummy_field()
        field_dict['instance'] = 'instance'

        db_create_field(self.store, field_dict, u'en')

        field_dict = helpers.get_dummy_field()
        field_dict['instance'] = 'template'
        field_dict['step_id'] = None
        fld_grp_id = self.store.find(Field, Field.fieldgroup_id is not None)[0].fieldgroup_id
        field_dict['field_id'] = fld_grp_id

        db_create_field(self.store, field_dict, u'en')
        self.store.commit()

        ret = perform_system_update()
        shutil.rmtree(GLSettings.db_path)
        self.assertNotEqual(ret, -1)
Exemplo n.º 2
0
    def test_check_field_constraints(self):
        # This test case asserts that a migration from db ver 32 up to 34 with
        # fields that fail the constraints still functions.
        self._initStartDB(32)

        field_dict = helpers.get_dummy_field()
        field_dict['instance'] = 'reference'
        field_dict['step_id'] = None
        field_dict['field_id'] = None

        db_create_field(self.store, field_dict, u'en')

        field_dict = helpers.get_dummy_field()
        field_dict['instance'] = 'instance'

        db_create_field(self.store, field_dict, u'en')

        field_dict = helpers.get_dummy_field()
        field_dict['instance'] = 'template'
        field_dict['step_id'] = None
        fld_grp_id = self.store.find(Field, Field.fieldgroup_id
                                     is not None)[0].fieldgroup_id
        field_dict['field_id'] = fld_grp_id

        db_create_field(self.store, field_dict, u'en')
        self.store.commit()

        ret = perform_system_update()
        shutil.rmtree(GLSettings.db_path)
        self.assertNotEqual(ret, -1)
Exemplo n.º 3
0
    def _test(self, path, f):
        helpers.init_glsettings_for_unit_tests()
        GLSettings.db_path = os.path.join(GLSettings.ramdisk_path, 'db_test')
        final_db_file = os.path.abspath(os.path.join(GLSettings.db_path, 'glbackend-%d.db' % DATABASE_VERSION))
        GLSettings.db_uri = GLSettings.make_db_uri(final_db_file)

        os.mkdir(GLSettings.db_path)
        dbpath = os.path.join(path, f)
        dbfile = os.path.join(GLSettings.db_path, f)
        shutil.copyfile(dbpath, dbfile)
        ret = perform_system_update()
        shutil.rmtree(GLSettings.db_path)
        self.assertNotEqual(ret, -1)
Exemplo n.º 4
0
    def _test(self, path, f):
        helpers.init_glsettings_for_unit_tests()
        GLSettings.db_path = os.path.join(GLSettings.ramdisk_path, 'db_test')
        final_db_file = os.path.abspath(
            os.path.join(GLSettings.db_path,
                         'glbackend-%d.db' % DATABASE_VERSION))
        GLSettings.db_uri = GLSettings.make_db_uri(final_db_file)

        os.mkdir(GLSettings.db_path)
        dbpath = os.path.join(path, f)
        dbfile = os.path.join(GLSettings.db_path, f)
        shutil.copyfile(dbpath, dbfile)
        ret = perform_system_update()
        shutil.rmtree(GLSettings.db_path)
        self.assertNotEqual(ret, -1)