Index: buildhelpers/codegen/templates/__init__test.mustache
===================================================================
--- buildhelpers/codegen/templates/__init__test.mustache	(revision 43fd35cf3f21ed781b31e4e1056072bbeced8e55)
+++ buildhelpers/codegen/templates/__init__test.mustache	(revision 43fd35cf3f21ed781b31e4e1056072bbeced8e55)
@@ -0,0 +1,67 @@
+import logging
+
+import flask
+import connexion
+from flask_cors import CORS
+from flask_testing import TestCase
+from flask_mail import Mail
+from sqlalchemy.event import listen
+from celery import Celery
+import tempfile
+import os
+from PIL import Image
+import shutil
+
+from {{packageName}}.encoder import JSONEncoder
+from {{packageName}}_impl.database.Model import (
+    db, db_setup, load_spatialite
+)
+from {{packageName}}_impl.tests import db_test_setup
+
+class BaseTestCase(TestCase):
+	def create_app(self):
+		logging.getLogger('connexion.operation').setLevel('ERROR')
+		app = connexion.App(__name__, specification_dir='../openapi/')
+		application = app.app
+		CORS(application)
+		mail = Mail()
+		application.json_encoder = JSONEncoder
+		app.add_api('openapi.yaml')
+
+		application.config.from_object('{{packageName}}_impl.Config.TestingConfig')
+		application.template_folder = os.path.join(os.path.dirname(__file__), '../../mapservice_impl/templates')
+		celery = Celery(__name__, broker=application.config['CELERY_BROKER_URL'])
+		celery.config_from_object(application.config)
+		mail.init_app(application)
+		db.init_app(application)
+		application.app_context().push()
+		
+		self._create_test_tile(application)
+		
+		return application
+
+	def setUp(self):
+		listen(db.engine, 'connect', load_spatialite)
+		db.drop_all()
+		# create the tables whether the database already exists or not
+		db_setup(True)
+		self.db_content = db_test_setup.DatabaseContent()
+		self.db_content.setup()
+        
+	def tearDown(self):
+		db.session.remove()
+		db.drop_all()
+		shutil.rmtree(self.tiles_cache)
+
+	def _create_test_tile(self, application):
+		self.tiles_cache = tempfile.mkdtemp(prefix='gnuboat-tests')
+		application.config['TILES_CACHE_PATH'] = self.tiles_cache
+		
+		tile_path = os.path.join(self.tiles_cache, '100_100/256/15/17298/')
+		os.makedirs(tile_path)
+		img = Image.new('RGBA', (100, 100), (255, 0, 0, 0))
+		img.save(os.path.join(tile_path, "21435.png"), "PNG")
+		
+	def check_key(self, key, value, data):
+		assert key in data, "{} not in data {}".format(key, data)
+		assert data[key] == value, "{} = {}".format(value, data[key])
