예제 #1
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"])
예제 #2
0
 def test_mongo_using_desk_filter_in_list(self):
     f = FilterCondition('desk', 'in', '1,2')
     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())
 def test_mongo_using_sms_filter_with_eq_comp(self):
     f = FilterCondition("sms", "eq", "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())
예제 #4
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"])
예제 #5
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"])
예제 #6
0
 def test_mongo_using_desk_filter_in_list(self):
     f = FilterCondition('desk', 'in', '1,2')
     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())
 def test_mongo_using_desk_filter_in_list(self):
     f = FilterCondition("desk", "in", "1,2")
     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())
예제 #8
0
 def test_mongo_using_embargo_filter_with_eq_comp(self):
     f = FilterCondition('embargo', 'eq', '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())
예제 #9
0
 def test_mongo_using_sms_filter_with_is(self):
     f = FilterCondition('sms', 'in', 'true')
     query = f.get_mongo_query()
     with self.app.app_context():
         docs = superdesk.get_resource_service('archive').\
             get_from_mongo(req=self.req, lookup=query)
         self.assertEqual(1, docs.count())
예제 #10
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"])
예제 #11
0
 def test_mongo_using_ingest_provider_filter_eq(self):
     f = FilterCondition("ingest_provider", "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"])
예제 #12
0
 def test_mongo_using_place_filter_complete_string(self):
     f = FilterCondition("place", "in", "NSW")
     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("11", docs[0]["_id"])
예제 #13
0
 def test_mongo_using_embargo_filter_with_eq_comp(self):
     f = FilterCondition('embargo', 'eq', '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())
예제 #14
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'])
예제 #15
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'])
예제 #16
0
 def test_mongo_using_like_filter_complete_string(self):
     f = FilterCondition('headline', 'like', 'story')
     query = f.get_mongo_query()
     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('1', docs[0]['_id'])
예제 #17
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 = superdesk.get_resource_service('archive').\
             get_from_mongo(req=self.req, lookup=query)
         self.assertEqual(1, docs.count())
         self.assertEqual('9', docs[0]['_id'])
예제 #18
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'])
예제 #19
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"])
예제 #20
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)
예제 #21
0
 def test_mongo_using_ingest_provider_filter_eq(self):
     f = FilterCondition('ingest_provider', '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'])
예제 #22
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'])
예제 #23
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'])
예제 #24
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'])
예제 #25
0
 def test_mongo_using_ingest_provider_filter_eq(self):
     f = FilterCondition('ingest_provider', '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'])
예제 #26
0
 def test_mongo_using_place_filter_complete_string(self):
     f = FilterCondition('place', 'in', 'NSW')
     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('11', docs[0]['_id'])
예제 #27
0
 def test_mongo_using_place_filter_complete_string(self):
     f = FilterCondition('place', 'in', 'NSW')
     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('11', docs[0]['_id'])
예제 #28
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'])
예제 #29
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'])
예제 #30
0
 def test_mongo_using_notin_filter(self):
     f = FilterCondition("urgency", "nin", "2,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(9, docs.count())
         doc_ids = [d["_id"] for d in docs]
         self.assertTrue("1" in doc_ids)
         self.assertTrue("2" in doc_ids)
예제 #31
0
 def test_mongo_using_like_filter_partial_string(self):
     f = FilterCondition("headline", "like", "tor")
     query = f.get_mongo_query()
     with self.app.app_context():
         docs = get_resource_service("archive").get_from_mongo(req=self.req, lookup=query)
         doc_ids = [d["_id"] for d in docs]
         self.assertEqual(2, docs.count())
         self.assertTrue("1" in doc_ids)
         self.assertTrue("2" in doc_ids)
예제 #32
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(10, docs.count())
         doc_ids = [d['_id'] for d in docs]
         self.assertTrue('2' not in doc_ids)
예제 #33
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'])
예제 #34
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(10, docs.count())
         doc_ids = [d['_id'] for d in docs]
         self.assertTrue('2' not in doc_ids)
예제 #35
0
 def test_mongo_using_like_filter_partial_string(self):
     f = FilterCondition('headline', 'like', 'tor')
     query = f.get_mongo_query()
     with self.app.app_context():
         docs = get_resource_service('archive'). \
             get_from_mongo(req=self.req, lookup=query)
         doc_ids = [d['_id'] for d in docs]
         self.assertEqual(2, docs.count())
         self.assertTrue('1' in doc_ids)
         self.assertTrue('2' in doc_ids)
예제 #36
0
 def test_mongo_using_notin_filter(self):
     f = FilterCondition('urgency', 'nin', '2,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(8, docs.count())
         doc_ids = [d['_id'] for d in docs]
         self.assertTrue('1' in doc_ids)
         self.assertTrue('2' in doc_ids)
예제 #37
0
 def test_mongo_using_notin_filter(self):
     f = FilterCondition('urgency', 'nin', '2,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(8, docs.count())
         doc_ids = [d['_id'] for d in docs]
         self.assertTrue('1' in doc_ids)
         self.assertTrue('2' in doc_ids)
예제 #38
0
 def test_mongo_using_like_filter_partial_string(self):
     f = FilterCondition('headline', 'like', 'tor')
     query = f.get_mongo_query()
     with self.app.app_context():
         docs = get_resource_service('archive'). \
             get_from_mongo(req=self.req, lookup=query)
         doc_ids = [d['_id'] for d in docs]
         self.assertEqual(2, docs.count())
         self.assertTrue('1' in doc_ids)
         self.assertTrue('2' in doc_ids)