Changeset ae2ff15 for src/mapservice/codegen
- Timestamp:
- Apr 10, 2020, 5:40:18 PM (7 years ago)
- Branches:
- debian/bullseye, master
- Children:
- 5c9c247
- Parents:
- ce59b61
- Location:
- src/mapservice/codegen
- Files:
-
- 6 edited
-
code_generator (modified) (4 diffs)
-
templates/__init__test.mustache (modified) (4 diffs)
-
templates/controller_test.mustache (modified) (2 diffs)
-
templates/setup.mustache (modified) (1 diff)
-
templates/test-requirements.mustache (modified) (1 diff)
-
templates/tox.mustache (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
src/mapservice/codegen/code_generator
rce59b61 rae2ff15 19 19 #fi 20 20 mkdir -p server_impl 21 cp -a ../../s rc/server_impl/* server_impl/21 cp -a ../../server_impl/* server_impl/ 22 22 #mv server_impl/CeleryWorker.py ./ 23 23 … … 44 44 #rm -R src-gen/openapi_server/static/.openapi* 45 45 46 # copying tests into auto generated test directory with test base class 47 cp -a tests/* src-gen/${PACKAGE_NAME}/test/ 48 46 49 ######## 47 50 # … … 59 62 chmod 0755 "${TOX_INSTALL_COMMAND}" 60 63 64 echo "include gnuboat_mapservice/openapi/*.yaml gnuboat_mapservice/templates/*" > "${SRC_GEN}/MANIFEST.in" 65 61 66 ######## 62 67 # … … 65 70 ######## 66 71 cd src-gen/ 67 tox > /tmp/openapi_tox.log72 tox 68 73 echo "###########################" 69 74 echo "#" -
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]) -
src/mapservice/codegen/templates/controller_test.mustache
rce59b61 rae2ff15 9 9 {{#imports}}{{import}} # noqa: E501 10 10 {{/imports}} 11 from {{packageName}}.testimport BaseTestCase11 from . import BaseTestCase 12 12 13 13 … … 34 34 'Content-Type': '{{mediaType}}',{{/vendorExtensions.x-prefered-consume}}{{#headerParams}} 35 35 '{{paramName}}': '{{{example}}}',{{/headerParams}}{{#authMethods}} 36 {{#isOAuth}}'Authorization': 'Bearer special-key',{{/isOAuth}}{{#isApiKey}}'X-API-KEY': 'test_key',{{/isApiKey}}{{#isBasicBasic}}'Authorization': 'BasicZm9vOmJhcg==',{{/isBasicBasic}}{{#isBasicBearer}}'Authorization': 'Bearer special-key',{{/isBasicBearer}}{{/authMethods}} 36 {{#isBasicBasic}}'Authorization': 'Basic YXV0b3Rlc3RzOmF1dG90ZXN0cw==',{{/isBasicBasic}} 37 {{/authMethods}} 37 38 } 38 39 {{#formParams}} -
src/mapservice/codegen/templates/setup.mustache
rce59b61 rae2ff15 41 41 keywords=["OpenAPI", "{{appName}}"], 42 42 install_requires=REQUIRES, 43 packages=find_packages( ),44 package_data={' ': ['openapi/openapi.yaml']},43 packages=find_packages(exclude=["*test*"]), 44 package_data={'{{packageName}}': ['openapi/openapi.yaml', 'templats/*']}, 45 45 include_package_data=True, 46 46 entry_points={ -
src/mapservice/codegen/templates/test-requirements.mustache
rce59b61 rae2ff15 1 1 flask_testing 2 2 coverage>=4.0.3 3 nose>=1.3.74 3 pluggy>=0.3.1 5 4 py>=1.4.31 6 requests 5 pytest 6 Pillow -
src/mapservice/codegen/templates/tox.mustache
rce59b61 rae2ff15 1 1 [tox] 2 envlist = {{#supportPython2}}py27, {{/supportPython2}}py32 envlist = py3 3 3 4 4 [testenv] 5 deps =-r{toxinidir}/requirements.txt6 -r{toxinidir}/test-requirements.txt5 deps = -r{toxinidir}/requirements.txt 6 -r{toxinidir}/test-requirements.txt 7 7 8 8 install_command = {toxinidir}/tox_install_command {opts} {packages} 9 9 10 commands= 11 nosetests \ 12 [] 10 commands = pytest
Note:
See TracChangeset
for help on using the changeset viewer.
