- Timestamp:
- Apr 10, 2020, 5:40:18 PM (7 years ago)
- Branches:
- debian/bullseye, master
- Children:
- 5c9c247
- Parents:
- ce59b61
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/mapservice/codegen/templates/__init__test.mustache
rce59b61 rae2ff15 5 5 from flask_cors import CORS 6 6 from flask_testing import TestCase 7 from flask_mail import Mail 7 8 from sqlalchemy.event import listen 8 9 from celery import Celery 10 import tempfile 11 import os 12 from PIL import Image 13 import shutil 9 14 10 15 from {{packageName}}.encoder import JSONEncoder 11 16 from {{packageName}}.server_impl.database.Model import db, db_setup, load_spatialite 12 from {{packageName}}.server_impl.demo import DbSetup as demoDbSetup17 from . import db_test_setup 13 18 14 19 class BaseTestCase(TestCase): … … 18 23 application = app.app 19 24 CORS(application) 25 mail = Mail() 20 26 application.json_encoder = JSONEncoder 21 27 app.add_api('openapi.yaml') … … 24 30 celery = Celery(__name__, broker=application.config['CELERY_BROKER_URL']) 25 31 celery.config_from_object(application.config) 32 mail.init_app(application) 26 33 db.init_app(application) 27 34 application.app_context().push() 35 36 self._create_test_tile(application) 28 37 29 38 return application … … 33 42 db.drop_all() 34 43 # create the tables whether the database already exists or not 35 db_setup(False) 36 demoDbSetup.setup() 44 db_setup(True) 45 self.db_content = db_test_setup.DatabaseContent() 46 self.db_content.setup() 37 47 38 48 def tearDown(self): 39 49 db.session.remove() 40 50 db.drop_all() 51 shutil.rmtree(self.tiles_cache) 52 53 def _create_test_tile(self, application): 54 self.tiles_cache = tempfile.mkdtemp(prefix='gnuboat-tests') 55 application.config['TILES_CACHE_PATH'] = self.tiles_cache 56 57 tile_path = os.path.join(self.tiles_cache, '100_100/256/15/17298/') 58 os.makedirs(tile_path) 59 img = Image.new('RGBA', (100, 100), (255, 0, 0, 0)) 60 img.save(os.path.join(tile_path, "21435.png"), "PNG") 61 62 def check_key(self, key, value, data): 63 assert key in data, "{} not in data {}".format(key, data) 64 assert data[key] == value, "{} = {}".format(value, data[key])
Note:
See TracChangeset
for help on using the changeset viewer.
