Exemplo n.º 1
0
def test_url_modify(app):
    with app.app_context():

        url_path = modify_query('es_search.search', **{'date': '2001, 2002'})
        assert(url_path == '/search/?date=2001%2C+2002')

        url_path = modify_query('es_search.search', **{'date': '2001, 2002', 'q': 'elastic scattering'})
        assert(url_path == '/search/?date=2001%2C+2002&q=elastic+scattering')

        url_path = modify_query('es_search.search', **{'date': None, 'q': 'elastic scattering'})
        assert(url_path == '/search/?q=elastic+scattering')
Exemplo n.º 2
0
def test_url_modify(app):
    with app.app_context():

        url_path = modify_query('es_search.search', **{'date': '2001, 2002'})
        assert (url_path == '/search/?date=2001%2C+2002')

        url_path = modify_query(
            'es_search.search', **{
                'date': '2001, 2002',
                'q': 'elastic scattering'
            })
        assert (url_path == '/search/?date=2001%2C+2002&q=elastic+scattering')

        url_path = modify_query('es_search.search', **{
            'date': None,
            'q': 'elastic scattering'
        })
        assert (url_path == '/search/?q=elastic+scattering')
Exemplo n.º 3
0
def process_year_facet(request, facets):
    url_path = modify_query('.search', **{'date': None})
    year_facet = get_session_item(url_path)
    if len(year_facet) == 0 or (request.full_path[:-1] == url_path or request.full_path == url_path):
        # we update the facet if there is no value stored in the session,
        # or if the base url is the same as the stripped url
        year_facet = get_facet(facets, 'Date')
        if year_facet:
            year_facet = {decode_string(json.dumps(year_facet))}
            set_session_item(url_path, year_facet)

    if year_facet and len(year_facet) > 0:
        year_facet = list(year_facet)[0]

    return year_facet
Exemplo n.º 4
0
def process_year_facet(request, facets):
    url_path = modify_query('.search', **{'date': None})
    year_facet = get_session_item(url_path)
    if len(year_facet) == 0 or (request.full_path[:-1] == url_path or request.full_path == url_path):
        # we update the facet if there is no value stored in the session,
        # or if the base url is the same as the stripped url
        year_facet = get_facet(facets, 'Date')
        if year_facet:
            year_facet = {decode_string(json.dumps(year_facet))}
            set_session_item(url_path, year_facet)

    if year_facet and len(year_facet) > 0:
        year_facet = list(year_facet)[0]

    return year_facet