From 4f7e64c738f984c78815b87916d75e75dfa2bd70 Mon Sep 17 00:00:00 2001
From: thomaswoehlke <thomas.woehlke@gmail.com>
Date: Sat, 20 Feb 2021 20:11:26 +0100
Subject: [PATCH] working for 0.0.198 Release

---
 src/database.py   | 43 -------------------------------------------
 tests/conftest.py |  9 +++++----
 2 files changed, 5 insertions(+), 47 deletions(-)

diff --git a/src/database.py b/src/database.py
index cb9aeef3..0fca9ab4 100644
--- a/src/database.py
+++ b/src/database.py
@@ -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,
diff --git a/tests/conftest.py b/tests/conftest.py
index b9dc84a9..c9fb3684 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -1,24 +1,25 @@
 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)
-- 
GitLab