[schema migration] import refactoring to fix #1109558 and enhances things on the way
the main pb demonstrated by #1109558 was due to the fact that in-memory schema
was updated in commit_event of operations. This is undesired in most cases,
since we want the modification to be taken into account in the interval between
the modification detection and the commit_event.
I've fixed this by merging in-memory schema / database alteration operations
for most important changes, doing in-memory schema changes as they are detected
and implementing a revertcommit_event method to revert them if necessary (with
exception for removal of stuff from the schema, where this is simply done in a
postcommit_event methods).
Also, I've benefited from this to support reverting of database alteration for
some operations (more to be done there), and to move so system source alteration
code to the native source code for a nicer design.
There may be some more stuff in syncschema.py that would benefit from similar
changes, but most important things are done (at least to close #1109558, w/
unittest_syncschema and unittest_migration green).
# copyright 2003-2010 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
#
# This file is part of CubicWeb.
#
# CubicWeb is free software: you can redistribute it and/or modify it under the
# terms of the GNU Lesser General Public License as published by the Free
# Software Foundation, either version 2.1 of the License, or (at your option)
# any later version.
#
# CubicWeb is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
# details.
#
# You should have received a copy of the GNU Lesser General Public License along
# with CubicWeb. If not, see <http://www.gnu.org/licenses/>.
"""this module contains base classes for windmill integration"""
import os, os.path as osp
# imported by default to simplify further import statements
from logilab.common.testlib import unittest_main
from windmill.authoring import unit
from windmill.dep import functest
from cubicweb.devtools.httptest import CubicWebServerTC
class UnitTestReporter(functest.reports.FunctestReportInterface):
def summary(self, test_list, totals_dict, stdout_capture):
self.test_list = test_list
unittestreporter = UnitTestReporter()
functest.reports.register_reporter(unittestreporter)
class CubicWebWindmillUseCase(CubicWebServerTC, unit.WindmillUnitTestCase):
"""basic class for Windmill use case tests
:param browser: browser identification string (firefox|ie|safari|chrome) (firefox by default)
:param test_dir: testing file path or directory (./windmill by default)
"""
browser = 'firefox'
test_dir = osp.join(os.getcwd(), 'windmill')
def setUp(self):
# reduce log output
from logging import getLogger, ERROR
getLogger('cubicweb').setLevel(ERROR)
getLogger('logilab').setLevel(ERROR)
getLogger('windmill').setLevel(ERROR)
# Start CubicWeb session before running the server to populate self.vreg
CubicWebServerTC.setUp(self)
assert os.path.exists(self.test_dir), "provide 'test_dir' as the given test file/dir"
unit.WindmillUnitTestCase.setUp(self)
def tearDown(self):
unit.WindmillUnitTestCase.tearDown(self)
CubicWebServerTC.tearDown(self)
def testWindmill(self):
self.windmill_shell_objects['start_' + self.browser]()
self.windmill_shell_objects['do_test'](self.test_dir, threaded=False)
for test in unittestreporter.test_list:
self._testMethodDoc = getattr(test, "__doc__", None)
self._testMethodName = test.__name__
self.assertEquals(test.result, True)