[migration] Fix addition of entity type including boundary constraints on its own attributes
This was failing because of the sequence of sql executing when adding an
attribute:
1. add entity type <commit>
2. add relation type for attribute 1 <commit>
3. add attribute 1 and associated constraints <commit>
etc.
In the case of e.g. start/end constraint, we were trying to add the constraint
before addition of the constrained attribute (e.g. add constraint on 'start'
referencing 'end', but only 'start' has been added yet, not 'end').
This patch fix this by:
* adding the relation type to the schema without having to commit, but keeping
the operation to revert the addition if necessary - this allows to a single
commit for all attributes of the entity type ;
* using a LateOperation on constraint operation, so we ensure attributes are
actually added before any constraint is added.
[tox]
envlist =
check-manifest,flake8,
py{27,34}-{server,web,misc}
[testenv]
sitepackages = True
whitelist_externals =
/usr/bin/touch
deps =
-r{toxinidir}/requirements/dev.txt
py27: backports.tempfile
misc: -r{toxinidir}/requirements/test-misc.txt
server: -r{toxinidir}/requirements/test-server.txt
web: -r{toxinidir}/requirements/test-web.txt
commands =
py34: touch {envdir}/share/cubicweb/cubes/__init__.py
misc: {envpython} -m pip install --upgrade --no-deps --quiet git+git://github.com/logilab/yapps@master#egg=yapps
misc: {envpython} -m pytest {posargs} {toxinidir}/cubicweb/test {toxinidir}/cubicweb/dataimport/test {toxinidir}/cubicweb/devtools/test {toxinidir}/cubicweb/entities/test {toxinidir}/cubicweb/ext/test {toxinidir}/cubicweb/hooks/test {toxinidir}/cubicweb/sobjects/test {toxinidir}/cubicweb/wsgi/test {toxinidir}/cubicweb/pyramid/test
py27-misc: {envpython} -m pytest {posargs} {toxinidir}/cubicweb/etwist/test
server: {envpython} -m pytest {posargs} {toxinidir}/cubicweb/server/test
web: {envpython} -m pytest {posargs} {toxinidir}/cubicweb/web/test
[testenv:flake8]
skip_install = true
deps =
flake8 >= 3
whitelist_externals =
/bin/sh
commands = /bin/sh -c "flake8 `xargs -a {toxinidir}/flake8-ok-files.txt`"
[testenv:doc]
changedir = doc
deps =
sphinx
commands =
{envpython} -c 'import sphinx; sphinx.main()' -b html -d {envtmpdir}/doctrees . {envtmpdir}/html
[testenv:check-manifest]
skip_install = true
deps =
check-manifest
commands =
{envpython} -m check_manifest {toxinidir} \
# ignore symlinks that are not recognized by check-manifest, see
# https://github.com/mgedmin/check-manifest/issues/69
--ignore cubicweb/devtools/test/data/cubes/i18ntestcube*,cubicweb/test/data/legacy_cubes*
[pytest]
python_files = *test_*.py
[flake8]
format = pylint
ignore = W503
max-line-length = 100
exclude = setup.py,doc/*,cubicweb/misc/*,cubicweb/test/*,cubicweb/*/test/*,.tox/*
# vim: wrap sts=2 sw=2