Skip to content

Commit

Permalink
issue #105 - rename alembicVerify toxenv and pytest marker to more ge…
Browse files Browse the repository at this point in the history
…neric 'migrations'
  • Loading branch information
jantman committed Feb 23, 2018
1 parent 26e307e commit c55c75a
Showing 6 changed files with 45 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -36,7 +36,7 @@ matrix:
- python: "3.6"
env: TOXENV=acceptance36 DB_CONNSTRING='mysql+pymysql://root@127.0.0.1:3306/budgettest36?charset=utf8mb4'
- python: "3.6"
env: TOXENV=alembicVerify MYSQL_USER='root' MYSQL_HOST='127.0.0.1' MYSQL_DBNAME_LEFT='alembicLeft' MYSQL_DBNAME_RIGHT='alembicRight'
env: TOXENV=migrations MYSQL_USER='root' MYSQL_HOST='127.0.0.1' MYSQL_DBNAME_LEFT='alembicLeft' MYSQL_DBNAME_RIGHT='alembicRight'
- python: "3.6"
env: TOXENV=docs

36 changes: 36 additions & 0 deletions biweeklybudget/tests/migrations/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
"""
The latest version of this package is available at:
<http://github.com/jantman/biweeklybudget>
################################################################################
Copyright 2016 Jason Antman <jason@jasonantman.com> <http://www.jasonantman.com>
This file is part of biweeklybudget, also known as biweeklybudget.
biweeklybudget is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
biweeklybudget 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 Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with biweeklybudget. If not, see <http://www.gnu.org/licenses/>.
The Copyright and Authors attributions contained herein may not be removed or
otherwise altered, except to add the Author attribution of a contributor to
this work. (Additional Terms pursuant to Section 7b of the AGPL v3)
################################################################################
While not legally required, I sincerely request that anyone who finds
bugs please submit them at <https://github.com/jantman/biweeklybudget> or
to me via email, and that you send any contributions or improvements
either as a pull request on GitHub, or to me via email.
################################################################################
AUTHORS:
Jason Antman <jason@jasonantman.com> <http://www.jasonantman.com>
################################################################################
"""
Original file line number Diff line number Diff line change
@@ -136,7 +136,7 @@ def load_premigration_sql(uri):
logger.info('Pre-migration DB state loaded into %s', engine.url.database)


@pytest.mark.alembicVerify
@pytest.mark.migrations
def test_upgrade_and_downgrade(uri_left, alembic_config_left):
"""Test all migrations up and down.
@@ -158,7 +158,7 @@ def test_upgrade_and_downgrade(uri_left, alembic_config_left):
current = get_current_revision(alembic_config_left, engine, script)


@pytest.mark.alembicVerify
@pytest.mark.migrations
def test_model_and_migration_schemas_are_the_same(
uri_left, uri_right, alembic_config_left
):
3 changes: 2 additions & 1 deletion docs/source/development.rst
Original file line number Diff line number Diff line change
@@ -98,9 +98,10 @@ end with a trailing slash.
Alembic Migration Verification
++++++++++++++++++++++++++++++

There is an ``alembicVerify`` tox environment that runs `alembic-verify <http://alembic-verify.readthedocs.io/en/latest/>`_
There is an ``migrations`` tox environment that runs `alembic-verify <http://alembic-verify.readthedocs.io/en/latest/>`_
tests on migrations. This tests running through all upgrade migrations in order and then all downgrade migrations
in order, and also tests that the latest (head) migration revision matches the current state of the models.
The environment also runs manually-curated acceptance tests for any migrations that involve data manipulation.

This tox environment is configured via environment variables. Please note that it requires *two* test databases.

2 changes: 1 addition & 1 deletion pytest.ini
Original file line number Diff line number Diff line change
@@ -14,7 +14,7 @@ pep8maxlinelength = 80
markers =
integration: tests that connect to an actual database
acceptance: tests that use the real Flask app over HTTP
alembicVerify: tests that run alembic-verify to verify migrations
migrations: tests and verifies database migrations
sensitive_url = example\.com
# timeout tests after 2 minutes
timeout = 360
6 changes: 3 additions & 3 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tox]
envlist = py27,py34,py35,py36,docs,jsdoc,screenshots,acceptance27,acceptance36,docker,alembicVerify
envlist = py27,py34,py35,py36,docs,jsdoc,screenshots,acceptance27,acceptance36,docker,migrations

[testenv]
deps =
@@ -157,7 +157,7 @@ sitepackages = False
whitelist_externals = env test
commands = {[testenv:acceptance27]commands}

[testenv:alembicVerify]
[testenv:migrations]
deps =
-r{toxinidir}/requirements.txt
execnet
@@ -178,4 +178,4 @@ commands =
virtualenv --version
pip --version
pip freeze
py.test -rxs -vv --durations=50 --durations-file=results/test_durations.json --html=results/alembicVerify.html -m "alembicVerify" biweeklybudget
py.test -rxs -vv --durations=50 --durations-file=results/test_durations.json --html=results/migrations.html -m "migrations" biweeklybudget

0 comments on commit c55c75a

Please sign in to comment.