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


Python filter_condition.FilterConditionService类代码示例

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


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

示例1: test_mongo_using_endswith_filter

 def test_mongo_using_endswith_filter(self):
     f = FilterConditionService()
     doc = {'field': 'headline', 'operator': 'endswith', 'value': 'Que'}
     query = f.get_mongo_query(doc)
     with self.app.app_context():
         docs = superdesk.get_resource_service('archive').\
             get_from_mongo(req=self.req, lookup=query)
         self.assertEqual(1, docs.count())
         self.assertEqual('2', docs[0]['_id'])
开发者ID:oxcarh,项目名称:superdesk,代码行数:9,代码来源:filter_condition_tests.py

示例2: test_does_match_with_notlike_filter

 def test_does_match_with_notlike_filter(self):
     f = FilterConditionService()
     doc = {'field': 'headline', 'operator': 'notlike', 'value': 'Que'}
     self.assertTrue(f.does_match(doc, self.articles[0]))
     self.assertFalse(f.does_match(doc, self.articles[1]))
     self.assertTrue(f.does_match(doc, self.articles[2]))
     self.assertTrue(f.does_match(doc, self.articles[3]))
     self.assertTrue(f.does_match(doc, self.articles[4]))
     self.assertTrue(f.does_match(doc, self.articles[5]))
开发者ID:oxcarh,项目名称:superdesk,代码行数:9,代码来源:filter_condition_tests.py

示例3: test_elastic_using_endswith_filter

 def test_elastic_using_endswith_filter(self):
     f = FilterConditionService()
     doc = {'field': 'headline', 'operator': 'endswith', 'value': 'Que'}
     query = f.get_elastic_query(doc)
     with self.app.app_context():
         self._setup_elastic_args(query, 'keyword')
         docs = superdesk.get_resource_service('archive').get(req=self.req, lookup=None)
         self.assertEqual(1, docs.count())
         self.assertEqual('2', docs[0]['_id'])
开发者ID:oxcarh,项目名称:superdesk,代码行数:9,代码来源:filter_condition_tests.py

示例4: test_does_match_with_nin_filter

 def test_does_match_with_nin_filter(self):
     f = FilterConditionService()
     doc = {'field': 'urgency', 'operator': 'nin', 'value': '2,3,4'}
     self.assertTrue(f.does_match(doc, self.articles[0]))
     self.assertTrue(f.does_match(doc, self.articles[1]))
     self.assertFalse(f.does_match(doc, self.articles[2]))
     self.assertFalse(f.does_match(doc, self.articles[3]))
     self.assertFalse(f.does_match(doc, self.articles[4]))
     self.assertTrue(f.does_match(doc, self.articles[5]))
开发者ID:oxcarh,项目名称:superdesk,代码行数:9,代码来源:filter_condition_tests.py

示例5: test_mongo_using_genre_filter_complete_string

 def test_mongo_using_genre_filter_complete_string(self):
     f = FilterConditionService()
     doc = {'field': 'genre', 'operator': 'in', 'value': 'Sidebar'}
     query = f.get_mongo_query(doc)
     with self.app.app_context():
         docs = superdesk.get_resource_service('archive').\
             get_from_mongo(req=self.req, lookup=query)
         self.assertEqual(1, docs.count())
         self.assertEqual('7', docs[0]['_id'])
开发者ID:oxcarh,项目名称:superdesk,代码行数:9,代码来源:filter_condition_tests.py

示例6: test_elastic_using_notlike_filter

 def test_elastic_using_notlike_filter(self):
     f = FilterConditionService()
     doc = {'field': 'headline', 'operator': 'notlike', 'value': 'que'}
     query = f.get_elastic_query(doc)
     with self.app.app_context():
         self._setup_elastic_args(query, 'not')
         docs = superdesk.get_resource_service('archive').get(req=self.req, lookup=None)
         self.assertEqual(7, docs.count())
         doc_ids = [d['_id'] for d in docs]
         self.assertTrue('2' not in doc_ids)
开发者ID:oxcarh,项目名称:superdesk,代码行数:10,代码来源:filter_condition_tests.py

示例7: test_elastic_using_subject_filter_complete_string

 def test_elastic_using_subject_filter_complete_string(self):
     f = FilterConditionService()
     doc = {'field': 'subject', 'operator': 'in', 'value': '05005003'}
     query = f.get_elastic_query(doc)
     with self.app.app_context():
         self._setup_elastic_args(query)
         docs = superdesk.get_resource_service('archive').get(req=self.req, lookup=None)
         doc_ids = [d['_id'] for d in docs]
         self.assertEqual(1, docs.count())
         self.assertTrue('8' in doc_ids)
开发者ID:oxcarh,项目名称:superdesk,代码行数:10,代码来源:filter_condition_tests.py

示例8: test_mongo_using_in_filter

 def test_mongo_using_in_filter(self):
     f = FilterConditionService()
     doc = {'field': 'urgency', 'operator': 'in', 'value': '3,4'}
     query = f.get_mongo_query(doc)
     with self.app.app_context():
         docs = superdesk.get_resource_service('archive').\
             get_from_mongo(req=self.req, lookup=query)
         self.assertEqual(2, docs.count())
         self.assertEqual('3', docs[0]['_id'])
         self.assertEqual('4', docs[1]['_id'])
开发者ID:oxcarh,项目名称:superdesk,代码行数:10,代码来源:filter_condition_tests.py

示例9: test_mongo_using_notlike_filter

 def test_mongo_using_notlike_filter(self):
     f = FilterConditionService()
     doc = {'field': 'headline', 'operator': 'notlike', 'value': 'Que'}
     query = f.get_mongo_query(doc)
     with self.app.app_context():
         docs = superdesk.get_resource_service('archive').\
             get_from_mongo(req=self.req, lookup=query)
         self.assertEqual(7, docs.count())
         doc_ids = [d['_id'] for d in docs]
         self.assertTrue('2' not in doc_ids)
开发者ID:oxcarh,项目名称:superdesk,代码行数:10,代码来源:filter_condition_tests.py

示例10: test_elastic_using_in_filter

 def test_elastic_using_in_filter(self):
     f = FilterConditionService()
     doc = {'field': 'urgency', 'operator': 'in', 'value': '3,4'}
     query = f.get_elastic_query(doc)
     with self.app.app_context():
         self._setup_elastic_args(query)
         docs = superdesk.get_resource_service('archive').get(req=self.req, lookup=None)
         doc_ids = [d['_id'] for d in docs]
         self.assertEqual(2, docs.count())
         self.assertTrue('4' in doc_ids)
         self.assertTrue('3' in doc_ids)
开发者ID:oxcarh,项目名称:superdesk,代码行数:11,代码来源:filter_condition_tests.py

示例11: test_get_mongo_operator

 def test_get_mongo_operator(self):
     f = FilterConditionService()
     self.assertEqual(f._get_mongo_operator('in'), '$in')
     self.assertEqual(f._get_mongo_operator('nin'), '$nin')
     self.assertEqual(f._get_mongo_operator('like'), '$regex')
     self.assertEqual(f._get_mongo_operator('notlike'), '$not')
     self.assertEqual(f._get_mongo_operator('startswith'), '$regex')
     self.assertEqual(f._get_mongo_operator('endswith'), '$regex')
开发者ID:oxcarh,项目名称:superdesk,代码行数:8,代码来源:filter_condition_tests.py

示例12: test_get_mongo_value

 def test_get_mongo_value(self):
     f = FilterConditionService()
     self.assertEqual(f._get_mongo_value('in', '1,2', 'urgency'), [1, 2])
     self.assertEqual(f._get_mongo_value('nin', '3', 'priority'), ['3'])
     self.assertEqual(f._get_mongo_value('like', 'test', 'headline'), re.compile('.*test.*', re.IGNORECASE))
     self.assertEqual(f._get_mongo_value('notlike', 'test', 'headline'), re.compile('.*test.*', re.IGNORECASE))
     self.assertEqual(f._get_mongo_value('startswith', 'test', 'headline'), re.compile('^test', re.IGNORECASE))
     self.assertEqual(f._get_mongo_value('endswith', 'test', 'headline'), re.compile('.*test', re.IGNORECASE))
开发者ID:oxcarh,项目名称:superdesk,代码行数:8,代码来源:filter_condition_tests.py

示例13: test_does_match_with_genre_filter

 def test_does_match_with_genre_filter(self):
     f = FilterConditionService()
     doc = {'field': 'genre', 'operator': 'in', 'value': 'Sidebar'}
     self.assertFalse(f.does_match(doc, self.articles[0]))
     self.assertFalse(f.does_match(doc, self.articles[1]))
     self.assertFalse(f.does_match(doc, self.articles[2]))
     self.assertFalse(f.does_match(doc, self.articles[3]))
     self.assertFalse(f.does_match(doc, self.articles[4]))
     self.assertFalse(f.does_match(doc, self.articles[5]))
     self.assertTrue(f.does_match(doc, self.articles[6]))
     self.assertFalse(f.does_match(doc, self.articles[7]))
开发者ID:oxcarh,项目名称:superdesk,代码行数:11,代码来源:filter_condition_tests.py

示例14: test_does_match_with_subject_filter

 def test_does_match_with_subject_filter(self):
     f = FilterConditionService()
     doc = {'field': 'subject', 'operator': 'in', 'value': '05005003'}
     self.assertFalse(f.does_match(doc, self.articles[0]))
     self.assertFalse(f.does_match(doc, self.articles[1]))
     self.assertFalse(f.does_match(doc, self.articles[2]))
     self.assertFalse(f.does_match(doc, self.articles[3]))
     self.assertFalse(f.does_match(doc, self.articles[4]))
     self.assertFalse(f.does_match(doc, self.articles[5]))
     self.assertFalse(f.does_match(doc, self.articles[6]))
     self.assertTrue(f.does_match(doc, self.articles[7]))
开发者ID:oxcarh,项目名称:superdesk,代码行数:11,代码来源:filter_condition_tests.py

示例15: test_does_match_with_category_filter

 def test_does_match_with_category_filter(self):
     f = FilterConditionService()
     doc = {'field': 'anpa_category', 'operator': 'in', 'value': 'a,i'}
     self.assertFalse(f.does_match(doc, self.articles[0]))
     self.assertFalse(f.does_match(doc, self.articles[1]))
     self.assertFalse(f.does_match(doc, self.articles[2]))
     self.assertFalse(f.does_match(doc, self.articles[3]))
     self.assertFalse(f.does_match(doc, self.articles[4]))
     self.assertFalse(f.does_match(doc, self.articles[5]))
     self.assertFalse(f.does_match(doc, self.articles[6]))
     self.assertFalse(f.does_match(doc, self.articles[7]))
     self.assertTrue(f.does_match(doc, self.articles[8]))
开发者ID:chalkjockey,项目名称:superdesk,代码行数:12,代码来源:filter_condition_tests.py


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