Repository: incubator-airflow Updated Branches: refs/heads/master ea13caa1e -> 6a668e741
[AIRFLOW-2678] Fix db schema unit test to remove checking fab models Project: http://git-wip-us.apache.org/repos/asf/incubator-airflow/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-airflow/commit/0c2206c7 Tree: http://git-wip-us.apache.org/repos/asf/incubator-airflow/tree/0c2206c7 Diff: http://git-wip-us.apache.org/repos/asf/incubator-airflow/diff/0c2206c7 Branch: refs/heads/master Commit: 0c2206c7d617fe4925ece6478dd5b6caf5b179ba Parents: 5646d31 Author: Tao feng <[email protected]> Authored: Tue Jun 26 00:23:11 2018 -0700 Committer: Tao feng <[email protected]> Committed: Tue Jun 26 15:22:19 2018 -0700 ---------------------------------------------------------------------- tests/utils/test_db.py | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-airflow/blob/0c2206c7/tests/utils/test_db.py ---------------------------------------------------------------------- diff --git a/tests/utils/test_db.py b/tests/utils/test_db.py index cb7b737..8ddd3ef 100644 --- a/tests/utils/test_db.py +++ b/tests/utils/test_db.py @@ -20,9 +20,8 @@ import unittest from airflow.models import Base as airflow_base -from flask_appbuilder.models.sqla import Base as fab_base -from airflow.settings import engine, RBAC +from airflow.settings import engine from alembic.autogenerate import compare_metadata from alembic.migration import MigrationContext from sqlalchemy import MetaData @@ -31,13 +30,9 @@ from sqlalchemy import MetaData class DbTest(unittest.TestCase): def test_database_schema_and_sqlalchemy_model_are_in_sync(self): - # combine Airflow and Flask-AppBuilder (if rbac enabled) models all_meta_data = MetaData() for (table_name, table) in airflow_base.metadata.tables.items(): all_meta_data._add_table(table_name, table.schema, table) - if RBAC: - for (table_name, table) in fab_base.metadata.tables.items(): - all_meta_data._add_table(table_name, table.schema, table) # create diff between database schema and SQLAlchemy model mc = MigrationContext.configure(engine.connect()) @@ -64,6 +59,23 @@ class DbTest(unittest.TestCase): t[1].name == 'celery_taskmeta'), lambda t: (t[0] == 'remove_table' and t[1].name == 'celery_tasksetmeta'), + # Ignore all the fab tables + lambda t: (t[0] == 'remove_table' and + t[1].name == 'ab_permission'), + lambda t: (t[0] == 'remove_table' and + t[1].name == 'ab_register_user'), + lambda t: (t[0] == 'remove_table' and + t[1].name == 'ab_role'), + lambda t: (t[0] == 'remove_table' and + t[1].name == 'ab_permission_view'), + lambda t: (t[0] == 'remove_table' and + t[1].name == 'ab_permission_view_role'), + lambda t: (t[0] == 'remove_table' and + t[1].name == 'ab_user_role'), + lambda t: (t[0] == 'remove_table' and + t[1].name == 'ab_user'), + lambda t: (t[0] == 'remove_table' and + t[1].name == 'ab_view_menu'), ] for ignore in ignores: diff = [d for d in diff if not ignore(d)]
