Esempio n. 1
0
 def test_create_sort_param_03(self):
     """sort direction input handled properly"""
     for sort_type, primary in config.SEARCH_SORT_OPTIONS_MAP.items():
         sort = create_sort_param(sort_type=sort_type, sort_dir='desc')
         self.assertEqual(sort, [(primary[0], 'desc'), config.SEARCH_DEFAULT_SECONDARY_SORT])
         sort = create_sort_param(sort_type=sort_type, sort_dir='asc')
         self.assertEqual(sort, [(primary[0], 'asc'), (config.SEARCH_DEFAULT_SECONDARY_SORT[0], 'asc')])
Esempio n. 2
0
 def test_create_sort_param_01(self):
     """no options should produce default values"""
     sort = create_sort_param()
     default_type = config.SEARCH_DEFAULT_SORT
     primary = config.SEARCH_SORT_OPTIONS_MAP[default_type]
     secondary = config.SEARCH_DEFAULT_SECONDARY_SORT
     self.assertEqual(sort, [primary,secondary])
Esempio n. 3
0
 def test_create_sort_param_04(self):
     """list type that doesn't appear in ABS_SORT_OPTIONS_MAP should get defaults"""
     sort = create_sort_param(list_type='foo')
     default_type = config.SEARCH_DEFAULT_SORT
     primary = config.SEARCH_SORT_OPTIONS_MAP[default_type]
     secondary = config.SEARCH_DEFAULT_SECONDARY_SORT
     self.assertEqual(sort, [primary,secondary])
Esempio n. 4
0
    view that retrieves the only bibcodes for a list of paper
    """
    #list of bibcodes to extract
    bibcodes_to_export = []
    list_type = request.values.get('list_type')
    numRecs   = request.values.get('numRecs', str(config.EXPORT_DEFAULT_ROWS))
    
    try:
        query_components = json.loads(request.values.get('current_search_parameters'))
    except (TypeError, JSONDecodeError), e:
        #@todo: logging of the error
        return ''
    #update the query parameters to return only what is necessary
    query_components.update({'facets':[], 'fields': ['bibcode'], 'highlights':[], 'rows': numRecs})
    if 'sort' not in query_components:
        query_components['sort'] = create_sort_param(list_type=list_type)

    #execute the query
    if list_type == 'similar':
        resp = get_document_similar(**query_components)
    else:
        req = solr.create_request(**query_components)
        url = None
        if 'bigquery' in request.values:
            from adsabs.core.solr import bigquery
            bigquery.prepare_bigquery_request(req, request.values['bigquery'])
            url = config.SOLRBIGQUERY_URL
        req = solr.set_defaults(req, query_url=url)
        resp = solr.get_response(req)

    if resp.is_error():
Esempio n. 5
0
 def test_create_sort_param_02(self):
     """sort type input should produce correct values from mapping"""
     for sort_type, primary in config.SEARCH_SORT_OPTIONS_MAP.items():
         sort = create_sort_param(sort_type=sort_type)
         self.assertEqual(sort, [primary, config.SEARCH_DEFAULT_SECONDARY_SORT])
Esempio n. 6
0
 def test_create_sort_param_06(self):
     """list type shouldn't override form input"""
     for list_type, lt_primary in config.ABS_SORT_OPTIONS_MAP.items():
         for sort_type, primary in config.SEARCH_SORT_OPTIONS_MAP.items():
             sort = create_sort_param(sort_type=sort_type, list_type=list_type)
             self.assertEqual(sort, [primary, config.SEARCH_DEFAULT_SECONDARY_SORT])
Esempio n. 7
0
 def test_create_sort_param_05(self):
     """list type in ABS_SORT_OPTIONS_MAP should get produce correct value"""
     for list_type, primary in config.ABS_SORT_OPTIONS_MAP.items():
         sort = create_sort_param(list_type=list_type)
         self.assertEqual(sort, [primary, config.SEARCH_DEFAULT_SECONDARY_SORT])