Ignore:
Timestamp:
Apr 26, 2020, 5:02:25 PM (7 years ago)
Author:
Joachim Langenbach <joachim.langenbach@…>
Branches:
debian/bullseye, master
Children:
62569d9
Parents:
691c4ca
Message:
  • Adapted code_generator to
    • handle several packages
    • to configure the port from yaml specification
    • to use the VERSION used by setup.py
  • Added deviceservice.yaml with first version of webservice
  • Moved Config loader and HttpErrors to gnuboat.common
  • Moved rrd archive schema to gnuboat.common.device
File:
1 edited

Legend:

Unmodified
Added
Removed
  • buildhelpers/codegen/templates/__init__test.mustache

    r691c4ca rf9321aa  
    1 import logging
     1from flask_testing import TestCase
    22
    3 import flask
    4 import connexion
    5 from flask_cors import CORS
    6 from flask_testing import TestCase
    7 from flask_mail import Mail
    8 from sqlalchemy.event import listen
    9 from celery import Celery
    10 import tempfile
    11 import os
    12 from PIL import Image
    13 import shutil
    14 
    15 from {{packageName}}.encoder import JSONEncoder
    16 from {{packageName}}_impl.database.Model import (
    17     db, db_setup, load_spatialite
     3from {{packageName}}_impl.tests import (
     4    create_app as orig_create_app,
     5    setUp as orig_setUp,
     6    tearDown as orig_tearDown
    187)
    19 from {{packageName}}_impl.tests import db_test_setup
    208
    219class BaseTestCase(TestCase):
    2210        def create_app(self):
    23                 logging.getLogger('connexion.operation').setLevel('ERROR')
    24                 app = connexion.App(__name__, specification_dir='../openapi/')
    25                 application = app.app
    26                 CORS(application)
    27                 mail = Mail()
    28                 application.json_encoder = JSONEncoder
    29                 app.add_api('openapi.yaml')
    30 
    31                 application.config.from_object('{{packageName}}_impl.Config.TestingConfig')
    32                 application.template_folder = os.path.join(os.path.dirname(__file__), '../../mapservice_impl/templates')
    33                 celery = Celery(__name__, broker=application.config['CELERY_BROKER_URL'])
    34                 celery.config_from_object(application.config)
    35                 mail.init_app(application)
    36                 db.init_app(application)
    37                 application.app_context().push()
    38                
    39                 self._create_test_tile(application)
    40                
    41                 return application
     11                return orig_create_app(self)
    4212
    4313        def setUp(self):
    44                 listen(db.engine, 'connect', load_spatialite)
    45                 db.drop_all()
    46                 # create the tables whether the database already exists or not
    47                 db_setup(True)
    48                 self.db_content = db_test_setup.DatabaseContent()
    49                 self.db_content.setup()
     14                orig_setUp(self)
    5015       
    5116        def tearDown(self):
    52                 db.session.remove()
    53                 db.drop_all()
    54                 shutil.rmtree(self.tiles_cache)
    55 
    56         def _create_test_tile(self, application):
    57                 self.tiles_cache = tempfile.mkdtemp(prefix='gnuboat-tests')
    58                 application.config['TILES_CACHE_PATH'] = self.tiles_cache
    59                
    60                 tile_path = os.path.join(self.tiles_cache, '100_100/256/15/17298/')
    61                 os.makedirs(tile_path)
    62                 img = Image.new('RGBA', (100, 100), (255, 0, 0, 0))
    63                 img.save(os.path.join(tile_path, "21435.png"), "PNG")
     17                orig_tearDown(self)
    6418               
    6519        def check_key(self, key, value, data):
Note: See TracChangeset for help on using the changeset viewer.