Skip to content
Snippets Groups Projects
Commit 4f7e64c7 authored by thomaswoehlke's avatar thomaswoehlke
Browse files

working for 0.0.198 Release

parent 75c07143
No related branches found
No related tags found
No related merge requests found
......@@ -23,37 +23,15 @@ def create_app():
return my_app
def create_app_test():
my_app = Flask('covid19test')
CORS(my_app)
Bootstrap(my_app)
my_app.config.from_object("config")
db_url_test = 'postgresql+psycopg2://{user}:{pw}@{url}/{db}'.format(
user=my_app.config['SQLALCHEMY_POSTGRES_USER'],
pw=my_app.config['SQLALCHEMY_POSTGRES_PW'],
url=my_app.config['SQLALCHEMY_POSTGRES_URL'],
db=my_app.config['SQLALCHEMY_POSTGRES_DB_TEST'])
my_app.config['SQLALCHEMY_DATABASE_URI'] = db_url_test
my_app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False # silence the deprecation warning
my_app.config['FLASK_ADMIN_SWATCH'] = 'superhero'
return my_app
def create_db(my_app):
my_db = SQLAlchemy(my_app)
my_db.create_all()
return my_db
def create_db_test(my_app):
my_db = SQLAlchemy(my_app)
return my_db
def create_celery(my_app):
celery = Celery(
my_app.import_name,
#namespace="covid19",
backend=my_app.config['MY_CELERY_RESULT_BACKEND'],
broker=my_app.config['CELERY_BROKER_URL'],
worker_send_task_events=my_app.config['CELERY_CONF_WORKER_SEND_TASK_EVENTS'],
......@@ -71,27 +49,6 @@ def create_celery(my_app):
return celery
def create_celery_test(my_app):
celery = Celery(
my_app.import_name,
#namespace="covid19",
backend=my_app.config['TEST_MY_CELERY_RESULT_BACKEND'],
broker=my_app.config['TEST_CELERY_BROKER_URL'],
worker_send_task_events=my_app.config['CELERY_CONF_WORKER_SEND_TASK_EVENTS'],
task_send_sent_event=my_app.config['CELERY_CONF_TASK_SEND_SENT_EVENT'],
broker_transport_options={'visibility_timeout': 18000, 'max_retries': 5}
)
celery.conf.update(my_app.config)
class ContextTask(celery.Task):
def __call__(self, *args, **kwargs):
with my_app.app_context():
return self.run(*args, **kwargs)
celery.Task = ContextTask
return celery
def create_admin(my_app):
my_admin = Admin(
my_app,
......
import os
import tempfile
import pytest
from database import create_app_test, create_db
from database import create_app, create_db, create_admin
@pytest.fixture
def app():
app = create_app_test()
app = create_app()
return app
@pytest.fixture
def client():
app = create_app_test()
app = create_app()
db_fd, app.config['DATABASE'] = tempfile.mkstemp()
app.config['TESTING'] = True
with app.test_client() as client:
with app.app_context():
create_db(app)
db = create_db(app)
admin = create_admin(app)
yield client
os.close(db_fd)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment