Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package python-Flask-Migrate for openSUSE:Factory checked in at 2023-05-21 19:09:02 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-Flask-Migrate (Old) and /work/SRC/openSUSE:Factory/.python-Flask-Migrate.new.1533 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-Flask-Migrate" Sun May 21 19:09:02 2023 rev:9 rq:1088117 version:4.0.4 Changes: -------- --- /work/SRC/openSUSE:Factory/python-Flask-Migrate/python-Flask-Migrate.changes 2023-01-05 15:01:40.081295662 +0100 +++ /work/SRC/openSUSE:Factory/.python-Flask-Migrate.new.1533/python-Flask-Migrate.changes 2023-05-21 19:09:48.814813671 +0200 @@ -1,0 +2,13 @@ +Sun May 21 09:11:46 UTC 2023 - Dirk Müller <dmuel...@suse.com> + +- update to 4.0.4: + * Correctly obtain database URL with SQLAlchemy 2.0 + * Remove legacy future import in Alembic templates + * Add SQLAlchemy 1.4 and 2.0 to the test matrix + * Switch to pytest as test runner + * Support "check" command + * Do not use deprecated functions in Flask-SQLAlchemy 3.0 + * Stop building Python 3.6 + * Remove tests from pypi package + +------------------------------------------------------------------- Old: ---- Flask-Migrate-4.0.0.tar.gz New: ---- Flask-Migrate-4.0.4.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-Flask-Migrate.spec ++++++ --- /var/tmp/diff_new_pack.GoZDao/_old 2023-05-21 19:09:49.766819105 +0200 +++ /var/tmp/diff_new_pack.GoZDao/_new 2023-05-21 19:09:49.810819356 +0200 @@ -16,8 +16,9 @@ # +%{?sle15_python_module_pythons} Name: python-Flask-Migrate -Version: 4.0.0 +Version: 4.0.4 Release: 0 Summary: SQLAlchemy database migrations for Flask applications using Alembic License: MIT @@ -27,13 +28,14 @@ Patch0: add-custom-template.patch BuildRequires: %{python_module Flask >= 0.9} BuildRequires: %{python_module Flask-SQLAlchemy >= 1.0} -BuildRequires: %{python_module alembic >= 0.7} +BuildRequires: %{python_module alembic >= 1.9.0} +BuildRequires: %{python_module base >= 3.7} BuildRequires: %{python_module setuptools} BuildRequires: fdupes BuildRequires: python-rpm-macros Requires: python-Flask >= 0.9 Requires: python-Flask-SQLAlchemy >= 1.0 -Requires: python-alembic >= 0.7 +Requires: python-alembic >= 1.9.0 BuildArch: noarch %python_subpackages ++++++ Flask-Migrate-4.0.0.tar.gz -> Flask-Migrate-4.0.4.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Flask-Migrate-4.0.0/PKG-INFO new/Flask-Migrate-4.0.4/PKG-INFO --- old/Flask-Migrate-4.0.0/PKG-INFO 2022-11-13 21:08:49.379917600 +0100 +++ new/Flask-Migrate-4.0.4/PKG-INFO 2023-02-03 00:22:31.447146700 +0100 @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: Flask-Migrate -Version: 4.0.0 +Version: 4.0.4 Summary: SQLAlchemy database migrations for Flask applications using Alembic. Home-page: https://github.com/miguelgrinberg/flask-migrate Author: Miguel Grinberg diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Flask-Migrate-4.0.0/setup.cfg new/Flask-Migrate-4.0.4/setup.cfg --- old/Flask-Migrate-4.0.0/setup.cfg 2022-11-13 21:08:49.380644800 +0100 +++ new/Flask-Migrate-4.0.4/setup.cfg 2023-02-03 00:22:31.448525200 +0100 @@ -1,6 +1,6 @@ [metadata] name = Flask-Migrate -version = 4.0.0 +version = 4.0.4 author = Miguel Grinberg author_email = miguel.grinb...@gmail.com license = MIT @@ -22,12 +22,12 @@ include_package_data = True package_dir = = src -packages = find: +packages = find_namespace: python_requires = >=3.6 install_requires = Flask >= 0.9 Flask-SQLAlchemy >= 1.0 - alembic >= 0.7 + alembic >= 1.9.0 [options.packages.find] where = src diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Flask-Migrate-4.0.0/src/Flask_Migrate.egg-info/PKG-INFO new/Flask-Migrate-4.0.4/src/Flask_Migrate.egg-info/PKG-INFO --- old/Flask-Migrate-4.0.0/src/Flask_Migrate.egg-info/PKG-INFO 2022-11-13 21:08:49.000000000 +0100 +++ new/Flask-Migrate-4.0.4/src/Flask_Migrate.egg-info/PKG-INFO 2023-02-03 00:22:31.000000000 +0100 @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: Flask-Migrate -Version: 4.0.0 +Version: 4.0.4 Summary: SQLAlchemy database migrations for Flask applications using Alembic. Home-page: https://github.com/miguelgrinberg/flask-migrate Author: Miguel Grinberg diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Flask-Migrate-4.0.0/src/Flask_Migrate.egg-info/SOURCES.txt new/Flask-Migrate-4.0.4/src/Flask_Migrate.egg-info/SOURCES.txt --- old/Flask-Migrate-4.0.0/src/Flask_Migrate.egg-info/SOURCES.txt 2022-11-13 21:08:49.000000000 +0100 +++ new/Flask-Migrate-4.0.4/src/Flask_Migrate.egg-info/SOURCES.txt 2023-02-03 00:22:31.000000000 +0100 @@ -27,14 +27,4 @@ src/flask_migrate/templates/flask-multidb/README src/flask_migrate/templates/flask-multidb/alembic.ini.mako src/flask_migrate/templates/flask-multidb/env.py -src/flask_migrate/templates/flask-multidb/script.py.mako -tests/__init__.py -tests/app.py -tests/app_compare_type1.py -tests/app_compare_type2.py -tests/app_custom_directory.py -tests/app_custom_directory_path.py -tests/app_multidb.py -tests/test_custom_template.py -tests/test_migrate.py -tests/test_multidb_migrate.py \ No newline at end of file +src/flask_migrate/templates/flask-multidb/script.py.mako \ No newline at end of file diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Flask-Migrate-4.0.0/src/Flask_Migrate.egg-info/requires.txt new/Flask-Migrate-4.0.4/src/Flask_Migrate.egg-info/requires.txt --- old/Flask-Migrate-4.0.0/src/Flask_Migrate.egg-info/requires.txt 2022-11-13 21:08:49.000000000 +0100 +++ new/Flask-Migrate-4.0.4/src/Flask_Migrate.egg-info/requires.txt 2023-02-03 00:22:31.000000000 +0100 @@ -1,3 +1,3 @@ Flask>=0.9 Flask-SQLAlchemy>=1.0 -alembic>=0.7 +alembic>=1.9.0 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Flask-Migrate-4.0.0/src/flask_migrate/__init__.py new/Flask-Migrate-4.0.4/src/flask_migrate/__init__.py --- old/Flask-Migrate-4.0.0/src/flask_migrate/__init__.py 2022-11-13 20:55:51.000000000 +0100 +++ new/Flask-Migrate-4.0.4/src/flask_migrate/__init__.py 2023-01-08 20:02:25.000000000 +0100 @@ -257,3 +257,10 @@ migrations""" config = current_app.extensions['migrate'].migrate.get_config(directory) command.stamp(config, revision, sql=sql, tag=tag) + + +@catch_errors +def check(directory=None): + """Check if there are any new operations to migrate""" + config = current_app.extensions['migrate'].migrate.get_config(directory) + command.check(config) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Flask-Migrate-4.0.0/src/flask_migrate/cli.py new/Flask-Migrate-4.0.4/src/flask_migrate/cli.py --- old/Flask-Migrate-4.0.0/src/flask_migrate/cli.py 2021-08-01 11:33:35.000000000 +0200 +++ new/Flask-Migrate-4.0.4/src/flask_migrate/cli.py 2023-01-08 20:02:25.000000000 +0100 @@ -14,6 +14,7 @@ from flask_migrate import branches as _branches from flask_migrate import current as _current from flask_migrate import stamp as _stamp +from flask_migrate import check as _check @click.group() @@ -239,3 +240,12 @@ """'stamp' the revision table with the given revision; don't run any migrations""" _stamp(directory, revision, sql, tag) + + +@db.command() +@click.option('-d', '--directory', default=None, + help=('Migration script directory (default is "migrations")')) +@with_appcontext +def check(directory): + """Check if there are any new operations to migrate""" + _check(directory) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Flask-Migrate-4.0.0/src/flask_migrate/templates/aioflask/env.py new/Flask-Migrate-4.0.4/src/flask_migrate/templates/aioflask/env.py --- old/Flask-Migrate-4.0.0/src/flask_migrate/templates/aioflask/env.py 2022-07-27 11:48:38.000000000 +0200 +++ new/Flask-Migrate-4.0.4/src/flask_migrate/templates/aioflask/env.py 2023-02-03 00:17:53.000000000 +0100 @@ -1,5 +1,3 @@ -from __future__ import with_statement - import asyncio import logging from logging.config import fileConfig @@ -17,14 +15,29 @@ fileConfig(config.config_file_name) logger = logging.getLogger('alembic.env') + +def get_engine(): + try: + # this works with Flask-SQLAlchemy<3 and Alchemical + return current_app.extensions['migrate'].db.get_engine() + except TypeError: + # this works with Flask-SQLAlchemy>=3 + return current_app.extensions['migrate'].db.engine + + +def get_engine_url(): + try: + return get_engine().url.render_as_string(hide_password=False).replace( + '%', '%%') + except AttributeError: + return str(get_engine().url).replace('%', '%%') + + # add your model's MetaData object here # for 'autogenerate' support # from myapp import mymodel # target_metadata = mymodel.Base.metadata -config.set_main_option( - 'sqlalchemy.url', - str(current_app.extensions['migrate'].db.get_engine().url).replace( - '%', '%%')) +config.set_main_option('sqlalchemy.url', get_engine_url()) target_db = current_app.extensions['migrate'].db # other values from the config, defined by the needs of env.py, @@ -90,7 +103,7 @@ """ - connectable = current_app.extensions['migrate'].db.get_engine() + connectable = get_engine() async with connectable.connect() as connection: await connection.run_sync(do_run_migrations) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Flask-Migrate-4.0.0/src/flask_migrate/templates/aioflask-multidb/env.py new/Flask-Migrate-4.0.4/src/flask_migrate/templates/aioflask-multidb/env.py --- old/Flask-Migrate-4.0.0/src/flask_migrate/templates/aioflask-multidb/env.py 2022-07-27 11:48:38.000000000 +0200 +++ new/Flask-Migrate-4.0.4/src/flask_migrate/templates/aioflask-multidb/env.py 2023-02-03 00:09:46.000000000 +0100 @@ -1,5 +1,3 @@ -from __future__ import with_statement - import asyncio import logging from logging.config import fileConfig @@ -20,14 +18,29 @@ fileConfig(config.config_file_name) logger = logging.getLogger('alembic.env') + +def get_engine(bind_key=None): + try: + # this works with Flask-SQLAlchemy<3 and Alchemical + return current_app.extensions['migrate'].db.get_engine(bind=bind_key) + except TypeError: + # this works with Flask-SQLAlchemy>=3 + return current_app.extensions['migrate'].db.engines.get(bind_key) + + +def get_engine_url(bind_key=None): + try: + return get_engine(bind_key).url.render_as_string( + hide_password=False).replace('%', '%%') + except AttributeError: + return str(get_engine(bind_key).url).replace('%', '%%') + + # add your model's MetaData object here # for 'autogenerate' support # from myapp import mymodel # target_metadata = mymodel.Base.metadata -config.set_main_option( - 'sqlalchemy.url', - str(current_app.extensions['migrate'].db.get_engine().url).replace( - '%', '%%')) +config.set_main_option('sqlalchemy.url', get_engine_url()) bind_names = [] if current_app.config.get('SQLALCHEMY_BINDS') is not None: bind_names = list(current_app.config['SQLALCHEMY_BINDS'].keys()) @@ -38,9 +51,7 @@ bind_names = get_bind_names() for bind in bind_names: context.config.set_section_option( - bind, "sqlalchemy.url", - str(current_app.extensions['migrate'].db.get_engine( - bind=bind).url).replace('%', '%%')) + bind, "sqlalchemy.url", get_engine_url(bind_key=bind)) target_db = current_app.extensions['migrate'].db @@ -166,12 +177,11 @@ # for the direct-to-DB use case, start a transaction on all # engines, then run all migrations, then commit all transactions. engines = { - '': {'engine': current_app.extensions['migrate'].db.get_engine()} + '': {'engine': get_engine()} } for name in bind_names: engines[name] = rec = {} - rec['engine'] = current_app.extensions['migrate'].db.get_engine( - bind=name) + rec['engine'] = get_engine(bind_key=name) for name, rec in engines.items(): engine = rec['engine'] diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Flask-Migrate-4.0.0/src/flask_migrate/templates/flask/env.py new/Flask-Migrate-4.0.4/src/flask_migrate/templates/flask/env.py --- old/Flask-Migrate-4.0.0/src/flask_migrate/templates/flask/env.py 2022-07-27 11:48:38.000000000 +0200 +++ new/Flask-Migrate-4.0.4/src/flask_migrate/templates/flask/env.py 2023-02-03 00:17:42.000000000 +0100 @@ -1,5 +1,3 @@ -from __future__ import with_statement - import logging from logging.config import fileConfig @@ -16,14 +14,29 @@ fileConfig(config.config_file_name) logger = logging.getLogger('alembic.env') + +def get_engine(): + try: + # this works with Flask-SQLAlchemy<3 and Alchemical + return current_app.extensions['migrate'].db.get_engine() + except TypeError: + # this works with Flask-SQLAlchemy>=3 + return current_app.extensions['migrate'].db.engine + + +def get_engine_url(): + try: + return get_engine().url.render_as_string(hide_password=False).replace( + '%', '%%') + except AttributeError: + return str(get_engine().url).replace('%', '%%') + + # add your model's MetaData object here # for 'autogenerate' support # from myapp import mymodel # target_metadata = mymodel.Base.metadata -config.set_main_option( - 'sqlalchemy.url', - str(current_app.extensions['migrate'].db.get_engine().url).replace( - '%', '%%')) +config.set_main_option('sqlalchemy.url', get_engine_url()) target_db = current_app.extensions['migrate'].db # other values from the config, defined by the needs of env.py, @@ -77,7 +90,7 @@ directives[:] = [] logger.info('No changes in schema detected.') - connectable = current_app.extensions['migrate'].db.get_engine() + connectable = get_engine() with connectable.connect() as connection: context.configure( diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Flask-Migrate-4.0.0/src/flask_migrate/templates/flask-multidb/env.py new/Flask-Migrate-4.0.4/src/flask_migrate/templates/flask-multidb/env.py --- old/Flask-Migrate-4.0.0/src/flask_migrate/templates/flask-multidb/env.py 2022-10-21 11:49:10.000000000 +0200 +++ new/Flask-Migrate-4.0.4/src/flask_migrate/templates/flask-multidb/env.py 2023-02-03 00:11:27.000000000 +0100 @@ -1,5 +1,3 @@ -from __future__ import with_statement - import logging from logging.config import fileConfig @@ -22,22 +20,26 @@ def get_engine(bind_key=None): try: - # this works with Flask-SQLAlchemy>=3 - return current_app.extensions['migrate'].db.get_engine( - bind_key=bind_key) - except TypeError: - # this works with Flask-SQLAlchemy<3 + # this works with Flask-SQLAlchemy<3 and Alchemical return current_app.extensions['migrate'].db.get_engine(bind=bind_key) + except TypeError: + # this works with Flask-SQLAlchemy>=3 + return current_app.extensions['migrate'].db.engines.get(bind_key) + + +def get_engine_url(bind_key=None): + try: + return get_engine(bind_key).url.render_as_string( + hide_password=False).replace('%', '%%') + except AttributeError: + return str(get_engine(bind_key).url).replace('%', '%%') # add your model's MetaData object here # for 'autogenerate' support # from myapp import mymodel # target_metadata = mymodel.Base.metadata -config.set_main_option( - 'sqlalchemy.url', - str(current_app.extensions['migrate'].db.get_engine().url).replace( - '%', '%%')) +config.set_main_option('sqlalchemy.url', get_engine_url()) bind_names = [] if current_app.config.get('SQLALCHEMY_BINDS') is not None: bind_names = list(current_app.config['SQLALCHEMY_BINDS'].keys()) @@ -48,8 +50,7 @@ bind_names = get_bind_names() for bind in bind_names: context.config.set_section_option( - bind, "sqlalchemy.url", - str(get_engine(bind_key=bind).url).replace('%', '%%')) + bind, "sqlalchemy.url", get_engine_url(bind_key=bind)) target_db = current_app.extensions['migrate'].db # other values from the config, defined by the needs of env.py, @@ -138,7 +139,7 @@ # for the direct-to-DB use case, start a transaction on all # engines, then run all migrations, then commit all transactions. engines = { - '': {'engine': current_app.extensions['migrate'].db.get_engine()} + '': {'engine': get_engine()} } for name in bind_names: engines[name] = rec = {} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Flask-Migrate-4.0.0/tests/app.py new/Flask-Migrate-4.0.4/tests/app.py --- old/Flask-Migrate-4.0.0/tests/app.py 2022-11-13 20:55:51.000000000 +0100 +++ new/Flask-Migrate-4.0.4/tests/app.py 1970-01-01 01:00:00.000000000 +0100 @@ -1,31 +0,0 @@ -#!/bin/env python -import os -from flask import Flask -from flask_sqlalchemy import SQLAlchemy -from flask_migrate import Migrate - -basedir = os.path.abspath(os.path.dirname(__file__)) - -app = Flask(__name__) -app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///' + os.path.join( - basedir, 'app.db') -app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False - -db = SQLAlchemy(app) -migrate = Migrate(app, db, compare_type=False) - - -class User(db.Model): - id = db.Column(db.Integer, primary_key=True) - name = db.Column(db.String(256)) - - -@app.cli.command() -def add(): - """Add test user.""" - db.session.add(User(name='test')) - db.session.commit() - - -if __name__ == '__main__': - app.run() diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Flask-Migrate-4.0.0/tests/app_compare_type1.py new/Flask-Migrate-4.0.4/tests/app_compare_type1.py --- old/Flask-Migrate-4.0.0/tests/app_compare_type1.py 2022-11-13 20:55:51.000000000 +0100 +++ new/Flask-Migrate-4.0.4/tests/app_compare_type1.py 1970-01-01 01:00:00.000000000 +0100 @@ -1,23 +0,0 @@ -import os -from flask import Flask -from flask_sqlalchemy import SQLAlchemy -from flask_migrate import Migrate - -basedir = os.path.abspath(os.path.dirname(__file__)) - -app = Flask(__name__) -app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///' + os.path.join( - basedir, 'app.db') -app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False - -db = SQLAlchemy(app) -migrate = Migrate(app, db, command='database') - - -class User(db.Model): - id = db.Column(db.Integer, primary_key=True) - name = db.Column(db.String(128)) - - -if __name__ == '__main__': - app.run() diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Flask-Migrate-4.0.0/tests/app_compare_type2.py new/Flask-Migrate-4.0.4/tests/app_compare_type2.py --- old/Flask-Migrate-4.0.0/tests/app_compare_type2.py 2022-11-13 20:55:51.000000000 +0100 +++ new/Flask-Migrate-4.0.4/tests/app_compare_type2.py 1970-01-01 01:00:00.000000000 +0100 @@ -1,23 +0,0 @@ -import os -from flask import Flask -from flask_sqlalchemy import SQLAlchemy -from flask_migrate import Migrate - -basedir = os.path.abspath(os.path.dirname(__file__)) - -app = Flask(__name__) -app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///' + os.path.join( - basedir, 'app.db') -app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False - -db = SQLAlchemy(app) -migrate = Migrate(app, db, command='database') - - -class User(db.Model): - id = db.Column(db.Integer, primary_key=True) - name = db.Column(db.String(10)) - - -if __name__ == '__main__': - app.run() diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Flask-Migrate-4.0.0/tests/app_custom_directory.py new/Flask-Migrate-4.0.4/tests/app_custom_directory.py --- old/Flask-Migrate-4.0.0/tests/app_custom_directory.py 2022-10-21 11:26:32.000000000 +0200 +++ new/Flask-Migrate-4.0.4/tests/app_custom_directory.py 1970-01-01 01:00:00.000000000 +0100 @@ -1,30 +0,0 @@ -import os -from flask import Flask -from flask_sqlalchemy import SQLAlchemy -from flask_migrate import Migrate - -basedir = os.path.abspath(os.path.dirname(__file__)) - -app = Flask(__name__) -app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///' + os.path.join( - basedir, 'app.db') -app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False - -db = SQLAlchemy(app) -migrate = Migrate(app, db, directory='temp_folder/temp_migrations') - - -class User(db.Model): - id = db.Column(db.Integer, primary_key=True) - name = db.Column(db.String(128)) - - -@app.cli.command() -def add(): - """Add test user.""" - db.session.add(User(name='test')) - db.session.commit() - - -if __name__ == '__main__': - app.run() diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Flask-Migrate-4.0.0/tests/app_custom_directory_path.py new/Flask-Migrate-4.0.4/tests/app_custom_directory_path.py --- old/Flask-Migrate-4.0.0/tests/app_custom_directory_path.py 2022-10-21 11:26:33.000000000 +0200 +++ new/Flask-Migrate-4.0.4/tests/app_custom_directory_path.py 1970-01-01 01:00:00.000000000 +0100 @@ -1,31 +0,0 @@ -import os -from flask import Flask -from flask_sqlalchemy import SQLAlchemy -from flask_migrate import Migrate -from pathlib import Path - -basedir = os.path.abspath(os.path.dirname(__file__)) - -app = Flask(__name__) -app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///' + os.path.join( - basedir, 'app.db') -app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False - -db = SQLAlchemy(app) -migrate = Migrate(app, db, directory=Path('temp_folder/temp_migrations')) - - -class User(db.Model): - id = db.Column(db.Integer, primary_key=True) - name = db.Column(db.String(128)) - - -@app.cli.command() -def add(): - """Add test user.""" - db.session.add(User(name='test')) - db.session.commit() - - -if __name__ == '__main__': - app.run() diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Flask-Migrate-4.0.0/tests/app_multidb.py new/Flask-Migrate-4.0.4/tests/app_multidb.py --- old/Flask-Migrate-4.0.0/tests/app_multidb.py 2022-10-21 11:26:34.000000000 +0200 +++ new/Flask-Migrate-4.0.4/tests/app_multidb.py 1970-01-01 01:00:00.000000000 +0100 @@ -1,43 +0,0 @@ -#!/bin/env python -import os -from flask import Flask -from flask_sqlalchemy import SQLAlchemy -from flask_migrate import Migrate - -basedir = os.path.abspath(os.path.dirname(__file__)) - -app = Flask(__name__) -app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///' + os.path.join( - basedir, 'app1.db') -app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False -app.config['SQLALCHEMY_BINDS'] = { - "db1": "sqlite:///" + os.path.join(basedir, "app2.db"), -} - -db = SQLAlchemy(app) - - -class User(db.Model): - id = db.Column(db.Integer, primary_key=True) - name = db.Column(db.String(128)) - - -class Group(db.Model): - __bind_key__ = 'db1' - id = db.Column(db.Integer, primary_key=True) - name = db.Column(db.String(128)) - - -migrate = Migrate(app, db) - - -@app.cli.command() -def add(): - """Add test users.""" - db.session.add(User(name='test')) - db.session.add(Group(name='group')) - db.session.commit() - - -if __name__ == '__main__': - app.run() diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Flask-Migrate-4.0.0/tests/test_custom_template.py new/Flask-Migrate-4.0.4/tests/test_custom_template.py --- old/Flask-Migrate-4.0.0/tests/test_custom_template.py 2022-10-21 11:20:52.000000000 +0200 +++ new/Flask-Migrate-4.0.4/tests/test_custom_template.py 1970-01-01 01:00:00.000000000 +0100 @@ -1,76 +0,0 @@ -import os -import shutil -import unittest -import subprocess -import shlex - - -def run_cmd(app, cmd): - """Run a command and return a tuple with (stdout, stderr, exit_code)""" - os.environ['FLASK_APP'] = app - process = subprocess.Popen(shlex.split(cmd), stdout=subprocess.PIPE, - stderr=subprocess.PIPE) - (stdout, stderr) = process.communicate() - print('\n$ ' + cmd) - print(stdout.decode('utf-8')) - print(stderr.decode('utf-8')) - return stdout, stderr, process.wait() - - -class TestMigrate(unittest.TestCase): - def setUp(self): - os.chdir(os.path.split(os.path.abspath(__file__))[0]) - try: - os.remove('app.db') - except OSError: - pass - try: - shutil.rmtree('migrations') - except OSError: - pass - try: - shutil.rmtree('temp_folder') - except OSError: - pass - - def tearDown(self): - try: - os.remove('app.db') - except OSError: - pass - try: - shutil.rmtree('migrations') - except OSError: - pass - try: - shutil.rmtree('temp_folder') - except OSError: - pass - - def test_alembic_version(self): - from flask_migrate import alembic_version - self.assertEqual(len(alembic_version), 3) - for v in alembic_version: - self.assertTrue(isinstance(v, int)) - - def test_migrate_upgrade(self): - (o, e, s) = run_cmd('app.py', 'flask db init -t ./custom_template') - self.assertTrue(s == 0) - (o, e, s) = run_cmd('app.py', 'flask db migrate') - self.assertTrue(s == 0) - (o, e, s) = run_cmd('app.py', 'flask db upgrade') - self.assertTrue(s == 0) - - from .app import app, db, User - with app.app_context(): - db.session.add(User(name='test')) - db.session.commit() - - with open('migrations/README', 'rt') as f: - assert f.readline().strip() == 'Custom template.' - with open('migrations/alembic.ini', 'rt') as f: - assert f.readline().strip() == '# Custom template' - with open('migrations/env.py', 'rt') as f: - assert f.readline().strip() == '# Custom template' - with open('migrations/script.py.mako', 'rt') as f: - assert f.readline().strip() == '# Custom template' diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Flask-Migrate-4.0.0/tests/test_migrate.py new/Flask-Migrate-4.0.4/tests/test_migrate.py --- old/Flask-Migrate-4.0.0/tests/test_migrate.py 2022-11-13 20:55:51.000000000 +0100 +++ new/Flask-Migrate-4.0.4/tests/test_migrate.py 1970-01-01 01:00:00.000000000 +0100 @@ -1,105 +0,0 @@ -import os -import shutil -import unittest -import subprocess -import shlex - - -def run_cmd(app, cmd): - """Run a command and return a tuple with (stdout, stderr, exit_code)""" - os.environ['FLASK_APP'] = app - process = subprocess.Popen(shlex.split(cmd), stdout=subprocess.PIPE, - stderr=subprocess.PIPE) - (stdout, stderr) = process.communicate() - print('\n$ ' + cmd) - print(stdout.decode('utf-8')) - print(stderr.decode('utf-8')) - return stdout, stderr, process.wait() - - -class TestMigrate(unittest.TestCase): - def setUp(self): - os.chdir(os.path.split(os.path.abspath(__file__))[0]) - try: - os.remove('app.db') - except OSError: - pass - try: - shutil.rmtree('migrations') - except OSError: - pass - try: - shutil.rmtree('temp_folder') - except OSError: - pass - - def tearDown(self): - try: - os.remove('app.db') - except OSError: - pass - try: - shutil.rmtree('migrations') - except OSError: - pass - try: - shutil.rmtree('temp_folder') - except OSError: - pass - - def test_alembic_version(self): - from flask_migrate import alembic_version - self.assertEqual(len(alembic_version), 3) - for v in alembic_version: - self.assertTrue(isinstance(v, int)) - - def test_migrate_upgrade(self): - (o, e, s) = run_cmd('app.py', 'flask db init') - self.assertTrue(s == 0) - (o, e, s) = run_cmd('app.py', 'flask db migrate') - self.assertTrue(s == 0) - (o, e, s) = run_cmd('app.py', 'flask db upgrade') - self.assertTrue(s == 0) - - from .app import app, db, User - with app.app_context(): - db.session.add(User(name='test')) - db.session.commit() - - def test_custom_directory(self): - (o, e, s) = run_cmd('app_custom_directory.py', 'flask db init') - self.assertTrue(s == 0) - (o, e, s) = run_cmd('app_custom_directory.py', 'flask db migrate') - self.assertTrue(s == 0) - (o, e, s) = run_cmd('app_custom_directory.py', 'flask db upgrade') - self.assertTrue(s == 0) - - from .app_custom_directory import app, db, User - with app.app_context(): - db.session.add(User(name='test')) - db.session.commit() - - def test_custom_directory_path(self): - (o, e, s) = run_cmd('app_custom_directory_path.py', 'flask db init') - self.assertTrue(s == 0) - (o, e, s) = run_cmd('app_custom_directory_path.py', 'flask db migrate') - self.assertTrue(s == 0) - (o, e, s) = run_cmd('app_custom_directory_path.py', 'flask db upgrade') - self.assertTrue(s == 0) - - from .app_custom_directory_path import app, db, User - with app.app_context(): - db.session.add(User(name='test')) - db.session.commit() - - def test_compare_type(self): - (o, e, s) = run_cmd('app_compare_type1.py', 'flask database init') - self.assertTrue(s == 0) - (o, e, s) = run_cmd('app_compare_type1.py', 'flask database migrate') - self.assertTrue(s == 0) - (o, e, s) = run_cmd('app_compare_type1.py', 'flask database upgrade') - self.assertTrue(s == 0) - (o, e, s) = run_cmd('app_compare_type2.py', 'flask database migrate') - self.assertTrue(s == 0) - self.assertTrue(b'Detected type change from VARCHAR(length=128) ' - b'to String(length=10)' in e) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Flask-Migrate-4.0.0/tests/test_multidb_migrate.py new/Flask-Migrate-4.0.4/tests/test_multidb_migrate.py --- old/Flask-Migrate-4.0.0/tests/test_multidb_migrate.py 2022-10-21 11:29:43.000000000 +0200 +++ new/Flask-Migrate-4.0.4/tests/test_multidb_migrate.py 1970-01-01 01:00:00.000000000 +0100 @@ -1,95 +0,0 @@ -import os -import shutil -import unittest -import subprocess -import shlex -import sqlite3 - - -def run_cmd(app, cmd): - """Run a command and return a tuple with (stdout, stderr, exit_code)""" - os.environ['FLASK_APP'] = app - process = subprocess.Popen(shlex.split(cmd), stdout=subprocess.PIPE, - stderr=subprocess.PIPE) - (stdout, stderr) = process.communicate() - print('\n$ ' + cmd) - print(stdout.decode('utf-8')) - print(stderr.decode('utf-8')) - return stdout, stderr, process.wait() - - -class TestMigrate(unittest.TestCase): - def setUp(self): - os.chdir(os.path.split(os.path.abspath(__file__))[0]) - try: - os.remove('app1.db') - os.remove('app2.db') - except OSError: - pass - try: - shutil.rmtree('migrations') - except OSError: - pass - - def tearDown(self): - try: - os.remove('app1.db') - os.remove('app2.db') - except OSError: - pass - try: - shutil.rmtree('migrations') - except OSError: - pass - - def test_multidb_migrate_upgrade(self): - (o, e, s) = run_cmd('app_multidb.py', 'flask db init --multidb') - self.assertTrue(s == 0) - (o, e, s) = run_cmd('app_multidb.py', 'flask db migrate') - self.assertTrue(s == 0) - (o, e, s) = run_cmd('app_multidb.py', 'flask db upgrade') - self.assertTrue(s == 0) - - # ensure the tables are in the correct databases - conn1 = sqlite3.connect('app1.db') - c = conn1.cursor() - c.execute('select name from sqlite_master') - tables = c.fetchall() - conn1.close() - self.assertIn(('alembic_version',), tables) - self.assertIn(('user',), tables) - - conn2 = sqlite3.connect('app2.db') - c = conn2.cursor() - c.execute('select name from sqlite_master') - tables = c.fetchall() - conn2.close() - self.assertIn(('alembic_version',), tables) - self.assertIn(('group',), tables) - - # ensure the databases can be written to - from .app_multidb import app, db, User, Group - with app.app_context(): - db.session.add(User(name='test')) - db.session.add(Group(name='group')) - db.session.commit() - - # ensure the downgrade works - (o, e, s) = run_cmd('app_multidb.py', 'flask db downgrade') - self.assertTrue(s == 0) - - conn1 = sqlite3.connect('app1.db') - c = conn1.cursor() - c.execute('select name from sqlite_master') - tables = c.fetchall() - conn1.close() - self.assertIn(('alembic_version',), tables) - self.assertNotIn(('user',), tables) - - conn2 = sqlite3.connect('app2.db') - c = conn2.cursor() - c.execute('select name from sqlite_master') - tables = c.fetchall() - conn2.close() - self.assertIn(('alembic_version',), tables) - self.assertNotIn(('group',), tables)