debian/bullseye
|
Last change
on this file since ce59b61 was be66b78, checked in by Joachim Langenbach <joachim.langenbach@…>, 7 years ago |
- Added Celery to the testing initialisation
- Ommitting log creation for demo puproses, if no CELERY_BROKER is set, because the tasks.delay() call never times out, if no broker is running
|
-
Property mode
set to
100644
|
|
File size:
1.2 KB
|
| Rev | Line | |
|---|
| [3a89adb] | 1 | import logging
|
|---|
| 2 |
|
|---|
| [be66b78] | 3 | import flask
|
|---|
| [3a89adb] | 4 | import connexion
|
|---|
| [be25db1] | 5 | from flask_cors import CORS
|
|---|
| [3a89adb] | 6 | from flask_testing import TestCase
|
|---|
| [fc99a86] | 7 | from sqlalchemy.event import listen
|
|---|
| [be66b78] | 8 | from celery import Celery
|
|---|
| [3a89adb] | 9 |
|
|---|
| 10 | from {{packageName}}.encoder import JSONEncoder
|
|---|
| [5ec7c42] | 11 | from {{packageName}}.server_impl.database.Model import db, db_setup, load_spatialite
|
|---|
| 12 | from {{packageName}}.server_impl.demo import DbSetup as demoDbSetup
|
|---|
| [fc99a86] | 13 |
|
|---|
| [3a89adb] | 14 | class BaseTestCase(TestCase):
|
|---|
| [be25db1] | 15 | def create_app(self):
|
|---|
| 16 | logging.getLogger('connexion.operation').setLevel('ERROR')
|
|---|
| 17 | app = connexion.App(__name__, specification_dir='../openapi/')
|
|---|
| 18 | application = app.app
|
|---|
| 19 | CORS(application)
|
|---|
| 20 | application.json_encoder = JSONEncoder
|
|---|
| 21 | app.add_api('openapi.yaml')
|
|---|
| [3a89adb] | 22 |
|
|---|
| [be25db1] | 23 | application.config.from_object('{{packageName}}.server_impl.Config.TestingConfig')
|
|---|
| [be66b78] | 24 | celery = Celery(__name__, broker=application.config['CELERY_BROKER_URL'])
|
|---|
| 25 | celery.config_from_object(application.config)
|
|---|
| [be25db1] | 26 | db.init_app(application)
|
|---|
| 27 | application.app_context().push()
|
|---|
| 28 |
|
|---|
| 29 | return application
|
|---|
| 30 |
|
|---|
| 31 | def setUp(self):
|
|---|
| [fc99a86] | 32 | listen(db.engine, 'connect', load_spatialite)
|
|---|
| [be25db1] | 33 | db.drop_all()
|
|---|
| [5ec7c42] | 34 | # create the tables whether the database already exists or not
|
|---|
| 35 | db_setup(False)
|
|---|
| 36 | demoDbSetup.setup()
|
|---|
| [be25db1] | 37 |
|
|---|
| 38 | def tearDown(self):
|
|---|
| 39 | db.session.remove()
|
|---|
| 40 | db.drop_all()
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.