-
-
Notifications
You must be signed in to change notification settings - Fork 229
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
wip: add test to check if a
Path
can be used as directory
parameter
- Loading branch information
Showing
3 changed files
with
61 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
from flask import Flask | ||
from flask_sqlalchemy import SQLAlchemy | ||
from flask_script import Manager | ||
from flask_migrate import Migrate, MigrateCommand | ||
|
||
app = Flask(__name__) | ||
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///app.db' | ||
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False | ||
|
||
db = SQLAlchemy(app) | ||
|
||
import sys | ||
directory = 'temp_folder/temp_migrations' | ||
if sys.version_info >= (3, 4): | ||
# For newer Python versions, we want to test that | ||
# a Path can be passed as directory parameter. | ||
from pathlib import Path | ||
directory = Path(directory) | ||
|
||
|
||
migrate = Migrate(app, db, directory=directory) | ||
|
||
manager = Manager(app) | ||
manager.add_command('db', MigrateCommand) | ||
|
||
|
||
class User(db.Model): | ||
id = db.Column(db.Integer, primary_key=True) | ||
name = db.Column(db.String(128)) | ||
|
||
|
||
@manager.command | ||
def add(): | ||
db.session.add(User(name='test')) | ||
db.session.commit() | ||
|
||
|
||
if __name__ == '__main__': | ||
manager.run() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters