Example #1
0
	def test_5_voting_popular(self):
		self.assertEqual(len(manager.get_top_posts()), 0)
		self.assertEqual(len(manager.get_popular_posts('How-to')), 0)
		manager.populate_test2()
		self.assertFalse(manager.vote_positive('8', 'fake-User'))
		self.assertFalse(manager.vote_negative('8', 'fake-User'))
		self.assertTrue(manager.vote_positive('1', 'seven'))
		self.assertFalse(manager.vote_positive('1', 'seven'))
		self.assertTrue(manager.vote_negative('2', 'panfrosio'))
		# get popular
		self.assertGreater(len(manager.get_top_posts()), 0)
		self.assertGreater(len(manager.get_popular_posts('How-to')), 0)
		self.assertGreater(len(manager.get_popular_tags()), 0)
Example #2
0
 def test_5_voting_popular(self):
     self.assertEqual(len(manager.get_top_posts()), 0)
     self.assertEqual(len(manager.get_popular_posts('How-to')), 0)
     manager.populate_test2()
     self.assertFalse(manager.vote_positive('8', 'fake-User'))
     self.assertFalse(manager.vote_negative('8', 'fake-User'))
     self.assertTrue(manager.vote_positive('1', 'seven'))
     self.assertFalse(manager.vote_positive('1', 'seven'))
     self.assertTrue(manager.vote_negative('2', 'panfrosio'))
     # get popular
     self.assertGreater(len(manager.get_top_posts()), 0)
     self.assertGreater(len(manager.get_popular_posts('How-to')), 0)
     self.assertGreater(len(manager.get_popular_tags()), 0)
Example #3
0
 def put(self, post_id): #Ok
     """ PUT request. Updates the value of the post by a vote up or down. """
     args = self.reqparse.parse_args()
     debug("(PUT) Vote to post " + str(post_id) + ". Vote up? " + str(args['up']))
     res = None
     if str(args['up']) == 'true':
         # vote up
         debug("voting up")
         res = manager.vote_positive(post_id, args['username'])
     elif str(args['up']) == 'false':
         # vote down
         debug("voting down")
         res = manager.vote_negative(post_id, args['username'])
     if res == None:
         return jsonify(error="Post-id not found", code="404")
     if res:
         return jsonify(message="Vote stored", code="200")
     else:
         return jsonify(error="Already voted on that post", code="405")
Example #4
0
 def put(self, post_id):  #Ok
     """ PUT request. Updates the value of the post by a vote up or down. """
     args = self.reqparse.parse_args()
     debug("(PUT) Vote to post " + str(post_id) + ". Vote up? " +
           str(args['up']))
     res = None
     if str(args['up']) == 'true':
         # vote up
         debug("voting up")
         res = manager.vote_positive(post_id, args['username'])
     elif str(args['up']) == 'false':
         # vote down
         debug("voting down")
         res = manager.vote_negative(post_id, args['username'])
     if res == None:
         return jsonify(error="Post-id not found", code="404")
     if res:
         return jsonify(message="Vote stored", code="200")
     else:
         return jsonify(error="Already voted on that post", code="405")