def realtime_place_bad_creation_test():
    """
    simple bss provider bad creation
    """

    with pytest.raises(Exception):
        manager = BssProviderManager((
            {
                'class': 'jormungandr.parking_space_availability.bss.tests.BssMockProvider'
            },
            {
                'class': 'jormungandr.parking_space_availability.bss.BadProvider'
            }
        ))
def realtime_journey_handle_test():
    """
    test that manager correctly populates "from" and "to" poi of a journey response
    """
    journeys = [
        {
            'sections': [
                {
                    'from': {
                        'embedded_type': 'poi',
                        'poi': {'id': 'station_1', 'poi_type': {'id': 'poi_type:amenity:bicycle_rental'}},
                        'id': 'station_1',
                    },
                    'to': {
                        'embedded_type': 'poi',
                        'poi': {'id': 'station_1', 'poi_type': {'id': 'poi_type:amenity:bicycle_rental'}},
                        'id': 'station_1',
                    },
                }
            ]
        }
    ]

    manager = BssProviderManager(CONFIG)
    manager.handle_journeys(journeys)
    journey_from = journeys[0]['sections'][0]['from']
    journey_to = journeys[0]['sections'][0]['to']
    assert 'stands' in journey_from['poi']
    assert 'stands' in journey_to['poi']

    assert journey_from['poi']['stands'].available_places == 5
    assert journey_from['poi']['stands'].available_bikes == 9
    assert journey_from['poi']['stands'].total_stands == 14
    assert journey_to['poi']['stands'].available_places == 5
    assert journey_to['poi']['stands'].available_bikes == 9
    assert journey_to['poi']['stands'].total_stands == 14
    assert journey_to['poi']['stands'].status == 'open'
def realtime_place_creation_test():
    """
    simple bss provider creation
    """
    manager = BssProviderManager(CONFIG)
    assert len(manager.bss_providers) == 1
Esempio n. 4
0
rest_api = Api(app, catch_all_404s=True, serve_challenge_on_401=True)

from navitiacommon.models import db
db.init_app(app)
cache = Cache(app, config=app.config['CACHE_CONFIGURATION'])

if app.config['AUTOCOMPLETE'] is not None:
    global_autocomplete = utils.create_object(app.config['AUTOCOMPLETE']['class_path'],
                                              **app.config['AUTOCOMPLETE']['kwargs'])
else:
    global_autocomplete = None


from jormungandr.instance_manager import InstanceManager

i_manager = InstanceManager(instances_dir=app.config.get('INSTANCES_DIR', None),
                            start_ping=app.config.get('START_MONITORING_THREAD', True))
i_manager.initialisation()

from jormungandr.stat_manager import StatManager
stat_manager = StatManager()

from jormungandr.parking_space_availability.bss.bss_provider_manager import BssProviderManager
bss_provider_manager = BssProviderManager(app.config['BSS_PROVIDER'])

from jormungandr import api

def setup_package():
    i_manager.stop()
Esempio n. 5
0
db.init_app(app)
cache = Cache(app, config=app.config['CACHE_CONFIGURATION'])

if app.config['AUTOCOMPLETE'] is not None:
    global_autocomplete = utils.create_object(
        app.config['AUTOCOMPLETE']['class_path'],
        **app.config['AUTOCOMPLETE']['kwargs'])
else:
    global_autocomplete = None

from jormungandr.instance_manager import InstanceManager

i_manager = InstanceManager(
    instances_dir=app.config.get('INSTANCES_DIR', None),
    start_ping=app.config.get('START_MONITORING_THREAD', True))
i_manager.initialisation()

from jormungandr.stat_manager import StatManager

stat_manager = StatManager()

from jormungandr.parking_space_availability.bss.bss_provider_manager import BssProviderManager

bss_provider_manager = BssProviderManager()

from jormungandr import api


def setup_package():
    i_manager.stop()