Exemplo n.º 1
0
 def test_3_post_search(self):
     # Posts by tag name
     self.assertIsNone(manager.search_tag_names_letter('He'))
     self.assertIsNone(manager.search_tag_names_letter('H', -2))
     self.assertIsNotNone(manager.search_tag_names_letter('H'))
     self.assertIsNotNone(manager.search_tag_names_letter('H', 1))
     # Posts by creation date
     manager.populate_test2()
     self.assertTrue(manager._is_user_created('seven'))
     self.assertIsNotNone(
         manager.search_posts_user_date('seven', 20141101, 20150101, 0))
     self.assertIsNotNone(
         manager.search_posts_user_date('seven', 20141101, 20150101, 1))
     self.assertEqual(
         len(manager.search_posts_user_date('seven', 20141101, 20150101,
                                            2)), 0)
     self.assertIsNone(
         manager.search_posts_user_date('', 20141101, 20150101, 2))
     # Search posts by title
     self.assertEqual(len(manager.search_posts_title('Z')), 0)
     self.assertEqual(len(manager.search_posts_title('How')), 2)
     self.assertEqual(len(manager.search_posts_title('How', 3)), 0)
     # Get posts with a certain tag
     self.assertEqual(len(manager.get_posts_with_tag('node.js')), 2)
     # Get index
     self.assertGreater(len(manager.get_index_letter_tag()), 0)
     self.assertGreater(len(manager.get_tags_by_index_letter('H')), 0)
Exemplo n.º 2
0
	def test_3_post_search(self):
		# Posts by tag name
		self.assertIsNone(manager.search_tag_names_letter('He'))
		self.assertIsNone(manager.search_tag_names_letter('H', -2))
		self.assertIsNotNone(manager.search_tag_names_letter('H'))
		self.assertIsNotNone(manager.search_tag_names_letter('H', 1))
		# Posts by creation date
		manager.populate_test2()
		self.assertTrue(manager._is_user_created('seven'))
		self.assertIsNotNone(manager.search_posts_user_date('seven', 20141101, 20150101, 0))
		self.assertIsNotNone(manager.search_posts_user_date('seven', 20141101, 20150101, 1))
		self.assertEqual(len(manager.search_posts_user_date('seven', 20141101, 20150101, 2)), 0)
		self.assertIsNone(manager.search_posts_user_date('', 20141101, 20150101, 2))
		# Search posts by title
		self.assertEqual(len(manager.search_posts_title('Z')), 0)
		self.assertEqual(len(manager.search_posts_title('How')), 2)
		self.assertEqual(len(manager.search_posts_title('How', 3)), 0)
		# Get posts with a certain tag
		self.assertEqual(len(manager.get_posts_with_tag('node.js')), 2)
		# Get index
		self.assertGreater(len(manager.get_index_letter_tag()), 0)
		self.assertGreater(len(manager.get_tags_by_index_letter('H')), 0)
Exemplo n.º 3
0
 def get(self):
     """ Search withing the posts given the title query. """
     args = self.reqparse.parse_args()
     page = args['page'] if args['page'] != None else 0
     posts = manager.search_posts_title(args['title'], page)
     return jsonify(posts=posts)
Exemplo n.º 4
0
 def get(self):
     """ Search withing the posts given the title query. """
     args = self.reqparse.parse_args()
     page = args['page'] if args['page'] != None else 0
     posts = manager.search_posts_title(args['title'], page)
     return jsonify(posts=posts)