当前位置: 首页>>代码示例>>Python>>正文


Python forms.QueryForm类代码示例

本文整理汇总了Python中adsabs.modules.search.forms.QueryForm的典型用法代码示例。如果您正苦于以下问题:Python QueryForm类的具体用法?Python QueryForm怎么用?Python QueryForm使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了QueryForm类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_init_with_defaults_01

 def test_init_with_defaults_01(self):
     """ test that defaults don't override inputs"""
     with self.app.test_request_context():
         QueryForm.default_if_missing = MultiDict([('db_f', '')])
         request_values = CombinedMultiDict([ImmutableMultiDict([('q', u' author:"civano"'), ('db_f', u'astronomy')]), ImmutableMultiDict([])])
         test_query = QueryForm.init_with_defaults(request_values)
         self.assertEqual(test_query.data['db_f'], 'astronomy')
开发者ID:giocalitri,项目名称:adslabs,代码行数:7,代码来源:test_modules_search.py

示例2: test_init_with_defaults_04

 def test_init_with_defaults_04(self):
     """ test that defaults get set """
     with self.app.test_request_context():
         QueryForm.default_if_missing = MultiDict([('db_f', 'foo')])
         request_values = CombinedMultiDict([ImmutableMultiDict([('q', u' author:"civano"')]), ImmutableMultiDict([])])
         test_query = QueryForm.init_with_defaults(request_values)
         self.assertEqual(test_query.data['db_f'], 'foo')
开发者ID:giocalitri,项目名称:adslabs,代码行数:7,代码来源:test_modules_search.py

示例3: test_only_query

    def test_only_query(self):
        """basic case"""
        with self.app.test_request_context('/search/?q=+author%3A"civano"'):
            expected = deepcopy(QueryBuilderSearch.DEFAULT_COMPONENTS)
            expected['q'] = u'( author:"civano")'
            expected['ui_q'] = u' author:"civano"'

            form = QueryForm.init_with_defaults(request.values)
            self.assertEqual(QueryBuilderSearch.build(form, request.values), expected)
开发者ID:giocalitri,项目名称:adslabs,代码行数:9,代码来源:test_modules_search.py

示例4: test_query_with_default_params_13

    def test_query_with_default_params_13(self):
        """with article only property"""
        with self.app.test_request_context('/search/?q=+author%3A"civano"&db_f=astronomy&article=y'):
            expected = deepcopy(QueryBuilderSearch.DEFAULT_COMPONENTS)
            expected['q'] = u'( author:"civano") AND NOT property:NONARTICLE AND database:"astronomy"'
            expected['ui_q'] = u' author:"civano"'
            expected['ui_filters'] = [u'database:"astronomy"']

            form = QueryForm.init_with_defaults(request.values)
            self.assertEqual(QueryBuilderSearch.build(form, request.values), expected)
开发者ID:giocalitri,项目名称:adslabs,代码行数:10,代码来源:test_modules_search.py

示例5: test_query_with_default_params_11

    def test_query_with_default_params_11(self):
        """with journal abbr fitler (wrong syntax)"""
        with self.app.test_request_context('/search/?q=+author%3A"civano"+bibstem%3A"ApJ%3B+AJ"&db_f=astronomy'):
            expected = deepcopy(QueryBuilderSearch.DEFAULT_COMPONENTS)
            expected['q'] = u'( author:"civano" bibstem:"ApJ; AJ") AND database:"astronomy"'
            expected['ui_q'] = u' author:"civano" bibstem:"ApJ; AJ"'
            expected['ui_filters'] = [u'database:"astronomy"',]

            form = QueryForm.init_with_defaults(request.values)
            self.assertEqual(QueryBuilderSearch.build(form, request.values), expected)
开发者ID:giocalitri,项目名称:adslabs,代码行数:10,代码来源:test_modules_search.py

示例6: test_query_with_default_params_12

    def test_query_with_default_params_12(self):
        """with refereed property"""
        with self.app.test_request_context('/search/?q=+author%3A"civano"&db_f=astronomy&prop_f=refereed'):
            expected = deepcopy(QueryBuilderSearch.DEFAULT_COMPONENTS)
            expected['q'] = u'( author:"civano") AND property:"refereed" AND database:"astronomy"'
            expected['ui_q'] = u' author:"civano"'
            expected['ui_filters'] = [u'property:"refereed"', u'database:"astronomy"']

            form = QueryForm.init_with_defaults(request.values)
            self.assertEqual(QueryBuilderSearch.build(form, request.values), expected)
开发者ID:giocalitri,项目名称:adslabs,代码行数:10,代码来源:test_modules_search.py

示例7: test_query_with_default_params_08

    def test_query_with_default_params_08(self):
        """with date range"""
        with self.app.test_request_context('/search/?q=+author%3A"civano"&db_f=astronomy&month_from=09&year_from=2009&year_to=2010'):
            expected = deepcopy(QueryBuilderSearch.DEFAULT_COMPONENTS)
            expected['q'] = u'( author:"civano") AND pubdate:[2009-09-00 TO 2010-12-00] AND database:"astronomy"'
            expected['ui_q'] = u' author:"civano"'
            expected['ui_filters'] = [u'pubdate:[2009-09-00 TO 2010-12-00]', u'database:"astronomy"',]

            form = QueryForm.init_with_defaults(request.values)
            self.assertEqual(QueryBuilderSearch.build(form, request.values), expected)
开发者ID:giocalitri,项目名称:adslabs,代码行数:10,代码来源:test_modules_search.py

示例8: test_query_with_default_params_04

    def test_query_with_default_params_04(self):
        """2nd order query"""
        with self.app.test_request_context('/search/?q=hot(galaxy+clusters)&db_f=astronomy'):
            expected = deepcopy(QueryBuilderSearch.DEFAULT_COMPONENTS)
            expected['q'] = u'(hot(galaxy clusters)) AND database:"astronomy"'
            expected['ui_q'] = u'hot(galaxy clusters)'
            expected['ui_filters'] = [u'database:"astronomy"']

            form = QueryForm.init_with_defaults(request.values)
            self.assertEqual(QueryBuilderSearch.build(form, request.values), expected)
开发者ID:giocalitri,项目名称:adslabs,代码行数:10,代码来源:test_modules_search.py

示例9: test_query_with_default_params_03

    def test_query_with_default_params_03(self):
        """non-default database filter"""
        with self.app.test_request_context('/search/?q=+author%3A"civano"&db_f=physics'):
            expected = deepcopy(QueryBuilderSearch.DEFAULT_COMPONENTS)
            expected['q'] = u'( author:"civano") AND database:"physics"'
            expected['ui_q'] = u' author:"civano"'
            expected['ui_filters'] = [u'database:"physics"']

            form = QueryForm.init_with_defaults(request.values)
            self.assertEqual(QueryBuilderSearch.build(form, request.values), expected)
开发者ID:giocalitri,项目名称:adslabs,代码行数:10,代码来源:test_modules_search.py

示例10: test_query_with_default_params_02

    def test_query_with_default_params_02(self):
        """including database filter (uppercase)"""
        with self.app.test_request_context('/search/?q=+author%3A"civano"&db_f=ASTRONOMY'):
            expected = deepcopy(QueryBuilderSearch.DEFAULT_COMPONENTS)
            expected['q'] = u'( author:"civano") AND database:"ASTRONOMY"'
            expected['ui_q'] = u' author:"civano"'
            expected['ui_filters'] = [u'database:"ASTRONOMY"']

            form = QueryForm.init_with_defaults(request.values)
            self.assertEqual(QueryBuilderSearch.build(form, request.values), expected)
开发者ID:giocalitri,项目名称:adslabs,代码行数:10,代码来源:test_modules_search.py

示例11: test_query_with_default_params_19

    def test_query_with_default_params_19(self):
        """with facet selection"""
        with self.app.test_request_context('/search/?q=*&db_f=astronomy&year_f=[2000 TO 2010]'):
            expected = deepcopy(QueryBuilderSearch.DEFAULT_COMPONENTS)
            expected['q'] = u'(*) AND year:[2000 TO 2010] AND database:"astronomy"'
            expected['ui_q'] = u'*'
            expected['ui_filters'] = [u'year:[2000 TO 2010]', 
                                   u'database:"astronomy"',]

            form = QueryForm.init_with_defaults(request.values)
            self.assertEqual(QueryBuilderSearch.build(form, request.values), expected)
开发者ID:giocalitri,项目名称:adslabs,代码行数:11,代码来源:test_modules_search.py

示例12: test_query_with_default_params_16

    def test_query_with_default_params_16(self):
        """with facet selection"""
        with self.app.test_request_context('/search/?q=author%3A"Civano"&db_f=astronomy&aut_f=-("1%2FCivano%2C+F%2FCivano%2C Francesca M."+OR+"1%2FElvis%2C M%2FElvis%2C Martin")'):
            expected = deepcopy(QueryBuilderSearch.DEFAULT_COMPONENTS)
            expected['q'] = u'(author:"Civano") AND NOT author_facet_hier:("1/Civano, F/Civano, Francesca M." OR "1/Elvis, M/Elvis, Martin") AND database:"astronomy"'
            expected['ui_q'] = u'author:"Civano"'
            expected['ui_filters'] = [u'-author_facet_hier:("1/Civano, F/Civano, Francesca M." OR "1/Elvis, M/Elvis, Martin")',
                                    u'database:"astronomy"',]

            form = QueryForm.init_with_defaults(request.values)
            self.assertEqual(QueryBuilderSearch.build(form, request.values), expected)
开发者ID:giocalitri,项目名称:adslabs,代码行数:11,代码来源:test_modules_search.py

示例13: test_query_with_default_params_25

    def test_query_with_default_params_25(self):
        """test topn operator"""
        with self.app.test_request_context('/search/?q=+author%3A"civano"&db_f=astronomy&re_sort_type=POPULARITY&re_sort_dir=asc&topn=1000'):
            expected = deepcopy(QueryBuilderSearch.DEFAULT_COMPONENTS)
            expected['q'] = u'topn(1000, (( author:"civano") AND database:"astronomy"), "read_count asc")'
            expected['ui_q'] = u' author:"civano"'
            expected['ui_filters'] = [u'database:"astronomy"']
            expected['sort'] = None

            form = QueryForm.init_with_defaults(request.values)
            actual = QueryBuilderSearch.build(form, request.values)
            self.assertEqual(actual, expected)
开发者ID:giocalitri,项目名称:adslabs,代码行数:12,代码来源:test_modules_search.py

示例14: test_query_with_default_params_22

    def test_query_with_default_params_22(self):
        """with different row count"""
        with self.app.test_request_context('/search/?q=+author%3A"civano"&db_f=astronomy&nr=33'):
            expected = deepcopy(QueryBuilderSearch.DEFAULT_COMPONENTS)
            expected['q'] = u'( author:"civano") AND database:"astronomy"'
            expected['ui_q'] = u' author:"civano"'
            expected['ui_filters'] = [u'database:"astronomy"']
            expected['rows'] = "33"

            form = QueryForm.init_with_defaults(request.values)
            actual = QueryBuilderSearch.build(form, request.values)
            self.assertEqual(actual, expected)
开发者ID:giocalitri,项目名称:adslabs,代码行数:12,代码来源:test_modules_search.py

示例15: test_query_with_default_params_26

    def test_query_with_default_params_26(self):
        """test no fulltext"""
        with self.app.test_request_context('/search/?q=civano&no_ft=1'):
            expected = deepcopy(QueryBuilderSearch.DEFAULT_COMPONENTS)
            expected['q'] = u'(civano)'
            expected['ui_q'] = u'civano'
            expected['ui_filters'] = []
            expected['query_fields'] = config.SOLR_SEARCH_DEFAULT_QUERY_FIELDS_METADATA_ONLY

            form = QueryForm.init_with_defaults(request.values)
            actual = QueryBuilderSearch.build(form, request.values)
            self.assertEqual(actual, expected)
开发者ID:giocalitri,项目名称:adslabs,代码行数:12,代码来源:test_modules_search.py


注:本文中的adsabs.modules.search.forms.QueryForm类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。