Exemple #1
0
def get_used_coverages_test():
    with app.test_request_context('/v1/coverage/fr-idf'):
        assert get_used_coverages() == ['fr-idf']

    with app.test_request_context('/v1/journeys'):
        register_used_coverages(['fr-bre'])
        assert get_used_coverages() == ['fr-bre']

    with app.test_request_context('/v1/journeys'):
        register_used_coverages('fr-bre')
        assert get_used_coverages() == ['fr-bre']
Exemple #2
0
 def fill_coverages(self, stat_request):
     coverages = get_used_coverages()
     if coverages:
         for coverage in coverages:
             stat_coverage = stat_request.coverages.add()
             stat_coverage.region_id = coverage
     else:
         # We need an empty coverage.
         stat_request.coverages.add()
Exemple #3
0
def add_info_newrelic(response, *args, **kwargs):
    try:
        record_custom_parameter('navitia-request-id', request.id)
        token = get_token()
        user = get_user(token=token, abort_if_no_token=False)
        app_name = get_app_name(token)
        if user:
            record_custom_parameter('user_id', str(user.id))
        record_custom_parameter('token_name', app_name)
        coverages = get_used_coverages()
        if coverages:
            record_custom_parameter('coverage', coverages[0])
    except:
        logger = logging.getLogger(__name__)
        logger.exception('error while reporting to newrelic:')
    return response