コード例 #1
0
 def test_mongo_using_in_filter(self):
     f = FilterCondition("urgency", "in", "3,4")
     query = f.get_mongo_query()
     with self.app.app_context():
         docs = 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"])
コード例 #2
0
 def test_does_match_with_like_partial(self):
     f = FilterCondition('headline', 'like', 'tor')
     self.assertTrue(f.does_match(self.articles[0]))
     self.assertTrue(f.does_match(self.articles[1]))
     self.assertFalse(f.does_match(self.articles[2]))
     self.assertFalse(f.does_match(self.articles[3]))
     self.assertFalse(f.does_match(self.articles[4]))
     self.assertFalse(f.does_match(self.articles[5]))
コード例 #3
0
 def test_does_match_with_notlike_filter(self):
     f = FilterCondition('headline', 'notlike', 'Que')
     self.assertTrue(f.does_match(self.articles[0]))
     self.assertFalse(f.does_match(self.articles[1]))
     self.assertTrue(f.does_match(self.articles[2]))
     self.assertTrue(f.does_match(self.articles[3]))
     self.assertTrue(f.does_match(self.articles[4]))
     self.assertTrue(f.does_match(self.articles[5]))
コード例 #4
0
 def test_mongo_using_like_filter_complete_string_eq(self):
     f = FilterCondition('headline', 'like', 'story')
     query = f.get_mongo_query()
     with self.app.app_context():
         docs = get_resource_service('archive'). \
             get_from_mongo(req=self.req, lookup=query)
         self.assertEqual(1, docs.count())
         self.assertEqual('1', docs[0]['_id'])
コード例 #5
0
 def test_does_match_with_eq(self):
     f = FilterCondition('urgency', 'eq', '1')
     self.assertTrue(f.does_match(self.articles[0]))
     self.assertFalse(f.does_match(self.articles[1]))
     self.assertFalse(f.does_match(self.articles[2]))
     self.assertFalse(f.does_match(self.articles[3]))
     self.assertFalse(f.does_match(self.articles[4]))
     self.assertFalse(f.does_match(self.articles[5]))
コード例 #6
0
 def test_mongo_using_priority_compare_lte_filter(self):
     f = FilterCondition('priority', 'lte', '3')
     query = f.get_mongo_query()
     with self.app.app_context():
         docs = get_resource_service('archive'). \
             get_from_mongo(req=self.req, lookup=query)
         self.assertEqual(1, docs.count())
         self.assertEqual('5', docs[0]['_id'])
コード例 #7
0
 def test_mongo_using_category_filter_complete_string(self):
     f = FilterCondition('anpa_category', 'in', 'a,i')
     query = f.get_mongo_query()
     with self.app.app_context():
         docs = get_resource_service('archive'). \
             get_from_mongo(req=self.req, lookup=query)
         self.assertEqual(1, docs.count())
         self.assertEqual('9', docs[0]['_id'])
コード例 #8
0
 def test_mongo_using_subject_filter_complete_string_eq(self):
     f = FilterCondition("subject", "eq", "05005003")
     query = f.get_mongo_query()
     with self.app.app_context():
         docs = get_resource_service("archive").get_from_mongo(req=self.req,
                                                               lookup=query)
         self.assertEqual(1, docs.count())
         self.assertEqual("8", docs[0]["_id"])
コード例 #9
0
 def test_mongo_using_like_filter_complete_string_eq(self):
     f = FilterCondition("headline", "like", "story")
     query = f.get_mongo_query()
     with self.app.app_context():
         docs = get_resource_service("archive").get_from_mongo(req=self.req,
                                                               lookup=query)
         self.assertEqual(1, docs.count())
         self.assertEqual("1", docs[0]["_id"])
コード例 #10
0
 def test_mongo_using_desk_filter_eq(self):
     f = FilterCondition("desk", "eq", "1")
     query = f.get_mongo_query()
     with self.app.app_context():
         docs = get_resource_service("archive").get_from_mongo(req=self.req,
                                                               lookup=query)
         self.assertEqual(1, docs.count())
         self.assertEqual("4", docs[0]["_id"])
コード例 #11
0
 def test_mongo_using_category_filter_complete_string(self):
     f = FilterCondition("anpa_category", "in", "a,i")
     query = f.get_mongo_query()
     with self.app.app_context():
         docs = get_resource_service("archive").get_from_mongo(req=self.req,
                                                               lookup=query)
         self.assertEqual(1, docs.count())
         self.assertEqual("9", docs[0]["_id"])
コード例 #12
0
 def test_mongo_using_priority_compare_lte_filter(self):
     f = FilterCondition("priority", "lte", "3")
     query = f.get_mongo_query()
     with self.app.app_context():
         docs = get_resource_service("archive").get_from_mongo(req=self.req,
                                                               lookup=query)
         self.assertEqual(1, docs.count())
         self.assertEqual("5", docs[0]["_id"])
コード例 #13
0
 def test_mongo_featuremedia_exists(self):
     f = FilterCondition("featuremedia", "exists", "true")
     query = f.get_mongo_query()
     with self.app.app_context():
         docs = get_resource_service("archive").get_from_mongo(req=self.req,
                                                               lookup=query)
         self.assertEqual(1, docs.count())
         self.assertEqual("4", docs[0]["_id"])
コード例 #14
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"])
コード例 #15
0
ファイル: tests.py プロジェクト: mscam/superdesk-core
 def test_does_match_with_nin_filter(self):
     f = FilterCondition('urgency', 'nin', '2,3,4')
     self.assertTrue(f.does_match(self.articles[0]))
     self.assertTrue(f.does_match(self.articles[1]))
     self.assertFalse(f.does_match(self.articles[2]))
     self.assertFalse(f.does_match(self.articles[3]))
     self.assertFalse(f.does_match(self.articles[4]))
     self.assertTrue(f.does_match(self.articles[5]))
コード例 #16
0
 def test_mongo_using_endswith_filter(self):
     f = FilterCondition("headline", "endswith", "Que")
     query = f.get_mongo_query()
     with self.app.app_context():
         docs = get_resource_service("archive").get_from_mongo(req=self.req,
                                                               lookup=query)
         self.assertEqual(1, docs.count())
         self.assertEqual("2", docs[0]["_id"])
コード例 #17
0
 def test_mongo_featuremedia_exists(self):
     f = FilterCondition('featuremedia', 'exists', 'true')
     query = f.get_mongo_query()
     with self.app.app_context():
         docs = get_resource_service('archive'). \
             get_from_mongo(req=self.req, lookup=query)
         self.assertEqual(1, docs.count())
         self.assertEqual('4', docs[0]['_id'])
コード例 #18
0
 def test_does_match_with_eq(self):
     f = FilterCondition("urgency", "eq", "1")
     self.assertTrue(f.does_match(self.articles[0]))
     self.assertFalse(f.does_match(self.articles[1]))
     self.assertFalse(f.does_match(self.articles[2]))
     self.assertFalse(f.does_match(self.articles[3]))
     self.assertFalse(f.does_match(self.articles[4]))
     self.assertFalse(f.does_match(self.articles[5]))
コード例 #19
0
 def test_mongo_using_desk_filter_eq(self):
     f = FilterCondition('desk', 'eq', '1')
     query = f.get_mongo_query()
     with self.app.app_context():
         docs = get_resource_service('archive'). \
             get_from_mongo(req=self.req, lookup=query)
         self.assertEqual(1, docs.count())
         self.assertEqual('4', docs[0]['_id'])
コード例 #20
0
 def test_does_match_with_eq_string(self):
     f = FilterCondition("headline", "eq", "Story")
     self.assertTrue(f.does_match(self.articles[0]))
     self.assertFalse(f.does_match(self.articles[1]))
     self.assertFalse(f.does_match(self.articles[2]))
     self.assertFalse(f.does_match(self.articles[3]))
     self.assertFalse(f.does_match(self.articles[4]))
     self.assertFalse(f.does_match(self.articles[5]))
コード例 #21
0
 def test_mongo_using_subject_filter_complete_string_eq(self):
     f = FilterCondition('subject', 'eq', '05005003')
     query = f.get_mongo_query()
     with self.app.app_context():
         docs = get_resource_service('archive'). \
             get_from_mongo(req=self.req, lookup=query)
         self.assertEqual(1, docs.count())
         self.assertEqual('8', docs[0]['_id'])
コード例 #22
0
 def test_does_match_with_like_full(self):
     f = FilterCondition("headline", "like", "story")
     self.assertTrue(f.does_match(self.articles[0]))
     self.assertFalse(f.does_match(self.articles[1]))
     self.assertFalse(f.does_match(self.articles[2]))
     self.assertFalse(f.does_match(self.articles[3]))
     self.assertFalse(f.does_match(self.articles[4]))
     self.assertFalse(f.does_match(self.articles[5]))
コード例 #23
0
 def test_mongo_using_endswith_filter(self):
     f = FilterCondition('headline', 'endswith', 'Que')
     query = f.get_mongo_query()
     with self.app.app_context():
         docs = get_resource_service('archive'). \
             get_from_mongo(req=self.req, lookup=query)
         self.assertEqual(1, docs.count())
         self.assertEqual('2', docs[0]['_id'])
コード例 #24
0
 def test_does_match_with_endswith_filter(self):
     f = FilterCondition("headline", "endswith", "Que")
     self.assertFalse(f.does_match(self.articles[0]))
     self.assertTrue(f.does_match(self.articles[1]))
     self.assertFalse(f.does_match(self.articles[2]))
     self.assertFalse(f.does_match(self.articles[3]))
     self.assertFalse(f.does_match(self.articles[4]))
     self.assertFalse(f.does_match(self.articles[5]))
コード例 #25
0
 def test_does_match_with_eq_string(self):
     f = FilterCondition('headline', 'eq', 'Story')
     self.assertTrue(f.does_match(self.articles[0]))
     self.assertFalse(f.does_match(self.articles[1]))
     self.assertFalse(f.does_match(self.articles[2]))
     self.assertFalse(f.does_match(self.articles[3]))
     self.assertFalse(f.does_match(self.articles[4]))
     self.assertFalse(f.does_match(self.articles[5]))
コード例 #26
0
 def test_does_match_with_nin_filter(self):
     f = FilterCondition("urgency", "nin", "2,3,4")
     self.assertTrue(f.does_match(self.articles[0]))
     self.assertTrue(f.does_match(self.articles[1]))
     self.assertFalse(f.does_match(self.articles[2]))
     self.assertFalse(f.does_match(self.articles[3]))
     self.assertFalse(f.does_match(self.articles[4]))
     self.assertTrue(f.does_match(self.articles[5]))
コード例 #27
0
 def test_does_match_with_startswith_filter(self):
     f = FilterCondition('headline', 'startswith', 'Sto')
     self.assertTrue(f.does_match(self.articles[0]))
     self.assertFalse(f.does_match(self.articles[1]))
     self.assertFalse(f.does_match(self.articles[2]))
     self.assertFalse(f.does_match(self.articles[3]))
     self.assertFalse(f.does_match(self.articles[4]))
     self.assertFalse(f.does_match(self.articles[5]))
コード例 #28
0
ファイル: tests.py プロジェクト: mscam/superdesk-core
 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'])
コード例 #29
0
 def test_mongo_using_notlike_filter(self):
     f = FilterCondition("headline", "notlike", "Que")
     query = f.get_mongo_query()
     with self.app.app_context():
         docs = get_resource_service("archive").get_from_mongo(req=self.req, lookup=query)
         self.assertEqual(11, docs.count())
         doc_ids = [d["_id"] for d in docs]
         self.assertTrue("2" not in doc_ids)
コード例 #30
0
ファイル: tests.py プロジェクト: vincerdesk/superdesk-core
 def test_mongo_using_in_filter(self):
     f = FilterCondition('urgency', 'in', '3,4')
     query = f.get_mongo_query()
     with self.app.app_context():
         docs = 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'])