コード例 #1
0
 def test_elastic_using_endswith_filter(self):
     f = FilterCondition('headline', 'endswith', 'Que')
     query = f.get_elastic_query()
     with self.app.app_context():
         self._setup_elastic_args(query, 'keyword')
         docs = get_resource_service('archive').get(req=self.req, lookup=None)
         self.assertEqual(1, docs.count())
         self.assertEqual('2', docs[0]['_id'])
コード例 #2
0
 def test_elastic_using_ingest_provider_filter_eq(self):
     f = FilterCondition('ingest_provider', 'eq', '1')
     query = f.get_elastic_query()
     with self.app.app_context():
         self._setup_elastic_args(query)
         docs = 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('4' in doc_ids)
コード例 #3
0
 def test_elastic_using_place_filter_complete_string(self):
     f = FilterCondition('place', 'match', 'NSW')
     query = f.get_elastic_query()
     with self.app.app_context():
         self._setup_elastic_args(query, 'match')
         docs = 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('11' in doc_ids)
コード例 #4
0
 def test_elastic_using_anpa_category_filter_complete_string(self):
     f = FilterCondition('anpa_category', 'in', 'a,i')
     query = f.get_elastic_query()
     with self.app.app_context():
         self._setup_elastic_args(query)
         docs = 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('9' in doc_ids)
コード例 #5
0
 def test_elastic_using_notlike_filter(self):
     f = FilterCondition('headline', 'notlike', 'que')
     query = f.get_elastic_query()
     with self.app.app_context():
         self._setup_elastic_args(query, 'not')
         docs = get_resource_service('archive').get(req=self.req, lookup=None)
         self.assertEqual(9, docs.count())
         doc_ids = [d['_id'] for d in docs]
         self.assertTrue('2' not in doc_ids)
コード例 #6
0
 def test_elastic_using_nin_filter(self):
     f = FilterCondition('urgency', 'nin', '3,4')
     query = f.get_elastic_query()
     with self.app.app_context():
         self._setup_elastic_args(query, 'not')
         docs = get_resource_service('archive').get(req=self.req, lookup=None)
         self.assertEqual(8, docs.count())
         doc_ids = [d['_id'] for d in docs]
         self.assertTrue('6' in doc_ids)
         self.assertTrue('5' in doc_ids)
コード例 #7
0
 def test_elastic_using_nin_filter(self):
     f = FilterCondition('urgency', 'nin', '3,4')
     query = f.get_elastic_query()
     with self.app.app_context():
         self._setup_elastic_args(query, 'not')
         docs = get_resource_service('archive').get(req=self.req,
                                                    lookup=None)
         self.assertEqual(8, docs.count())
         doc_ids = [d['_id'] for d in docs]
         self.assertTrue('6' in doc_ids)
         self.assertTrue('5' in doc_ids)
コード例 #8
0
ファイル: tests.py プロジェクト: liveblog/superdesk-core
 def test_elastic_using_like_filter(self):
     f = FilterCondition('headline', 'like', 'Tor')
     query = f.get_elastic_query()
     with self.app.app_context():
         self._setup_elastic_args(query, 'keyword')
         docs = get_resource_service('archive').get(req=self.req,
                                                    lookup=None)
         self.assertEqual(2, docs.count())
         doc_ids = [d['_id'] for d in docs]
         self.assertTrue('1' in doc_ids)
         self.assertTrue('2' in doc_ids)
コード例 #9
0
 def test_elastic_using_like_filter(self):
     f = FilterCondition("headline", "like", "Tor")
     query = f.get_elastic_query()
     with self.app.app_context():
         self._setup_elastic_args(query, "keyword")
         docs = get_resource_service("archive").get(req=self.req,
                                                    lookup=None)
         self.assertEqual(2, docs.count())
         doc_ids = [d["_id"] for d in docs]
         self.assertTrue("1" in doc_ids)
         self.assertTrue("2" in doc_ids)
コード例 #10
0
 def test_elastic_using_ne_filter(self):
     f = FilterCondition("urgency", "ne", "4")
     query = f.get_elastic_query()
     with self.app.app_context():
         self._setup_elastic_args(query, "not")
         docs = get_resource_service("archive").get(req=self.req,
                                                    lookup=None)
         self.assertEqual(9, docs.count())
         doc_ids = [d["_id"] for d in docs]
         self.assertTrue("6" in doc_ids)
         self.assertTrue("5" in doc_ids)