def test_add_existing_connection(): db_url = Config.get('app_schema').get('db_connection') adapter = DatabaseAdapter() adapter.add_connection(db_url) expected_length = len(adapter.get_connections()) adapter.add_connection(db_url) assert len(adapter.get_connections()) == expected_length
from pyramid_oereb.lib.config import Config from pyramid.config import Configurator from pyramid_oereb.lib.readers.exclusion_of_liability import ExclusionOfLiabilityReader from pyramid_oereb.lib.readers.extract import ExtractReader from pyramid_oereb.lib.readers.glossary import GlossaryReader from pyramid_oereb.lib.readers.municipality import MunicipalityReader from pyramid_oereb.lib.readers.real_estate import RealEstateReader from pyramid_oereb.lib.processor import Processor __version__ = '1.0.1' log = logging.getLogger(__name__) route_prefix = None # initially instantiate database adapter for global session handling database_adapter = DatabaseAdapter() processor = None def main(global_config, **settings): """ This function returns a Pyramid WSGI application. This is necessary for development of your plugin. So you can run it local with the paster server and in a IDE like PyCharm. It is intended to leave this section as is and do configuration in the includeme section only. Push additional configuration in this section means it will not be used by the production environment at all! """ config = Configurator(settings=settings) config.include('pyramid_oereb', route_prefix='oereb') config.scan() return config.make_wsgi_app()
def test_init(): adapter = DatabaseAdapter() assert isinstance(adapter._connections_, dict)
def test_get_connection_fail(): adapter = DatabaseAdapter() with pytest.raises(ArgumentError): adapter.get_session('not_a_connection_string')
def test_add_connection(): db_url = Config.get('app_schema').get('db_connection') adapter = DatabaseAdapter() adapter.add_connection(db_url) assert isinstance(adapter.get_session(db_url), Session)
def test_get_connections(): adapter = DatabaseAdapter() assert isinstance(adapter.get_connections(), dict)