Пример #1
0
 def get(self, id): #OK
     """ Gets a post given its id."""
     debug("GET POST id: " + str(id))
     post = manager.get_post(id)
     if post == None:
         return jsonify(error="Post-id not found", code="404")
     return {'post' : marshal(post, PostAPI.response_post_field)}
Пример #2
0
 def get(self, id):  #OK
     """ Gets a post given its id."""
     debug("GET POST id: " + str(id))
     post = manager.get_post(id)
     if post == None:
         return jsonify(error="Post-id not found", code="404")
     return {'post': marshal(post, PostAPI.response_post_field)}
Пример #3
0
	def test_1_user_none(self):
		# Before user creation
		self.assertFalse(manager._is_user_created('user'))
		self.assertFalse(manager.get_password('user'))
		self.assertIsNone(manager.get_user('user'))
		self.assertFalse(manager.change_password('user', 'some_pass'))
		self.assertFalse(manager.change_email('user', 'some_email'))
		self.assertFalse(manager.delete_user('user'))
		self.assertIsNone(manager.get_user_tags('user'))
		self.assertFalse(manager.add_favourite('user', '3'))
		self.assertFalse(manager.delete_favourite('user', '3'))
		self.assertIsNone(manager.get_favourites('user'))
		self.assertEqual(-1, manager.get_favourite_count('user'))
		self.assertIsNone(manager.get_post('8'))
		self.assertFalse(manager.delete_post('8', 'user'))
		self.assertIsNone(manager.get_posts('user'))
Пример #4
0
 def test_1_user_none(self):
     # Before user creation
     self.assertFalse(manager._is_user_created('user'))
     self.assertFalse(manager.get_password('user'))
     self.assertIsNone(manager.get_user('user'))
     self.assertFalse(manager.change_password('user', 'some_pass'))
     self.assertFalse(manager.change_email('user', 'some_email'))
     self.assertFalse(manager.delete_user('user'))
     self.assertIsNone(manager.get_user_tags('user'))
     self.assertFalse(manager.add_favourite('user', '3'))
     self.assertFalse(manager.delete_favourite('user', '3'))
     self.assertIsNone(manager.get_favourites('user'))
     self.assertEqual(-1, manager.get_favourite_count('user'))
     self.assertIsNone(manager.get_post('8'))
     self.assertFalse(manager.delete_post('8', 'user'))
     self.assertIsNone(manager.get_posts('user'))
Пример #5
0
 def put(self, id): # OK
     """ Handles PUT request. Updates an existing post data."""
     debug("PUT POST id:" +  str(id))
     post = manager.get_post(id)
     if post == None:
         abort(404)
     args = self.reqparse.parse_args()
     if 'username' in args.keys():
         username = args['username']
         if 'title' in args.keys():
             post['title'] = args['title']
         if 'contents' in args.keys():
             post['contents'] = args['contents']
         if 'tags' in args.keys():
             post['tags'] = list([b64decode(temp) \
                 for temp in args['tags'].split(':')])
         else:
             post['tags'] = []
         post = manager.update_post(post, id, username)
         return {'post': marshal(post, PostAPI.response_post_field)}
     else:
         abort(400)
Пример #6
0
 def put(self, id):  # OK
     """ Handles PUT request. Updates an existing post data."""
     debug("PUT POST id:" + str(id))
     post = manager.get_post(id)
     if post == None:
         abort(404)
     args = self.reqparse.parse_args()
     if 'username' in args.keys():
         username = args['username']
         if 'title' in args.keys():
             post['title'] = args['title']
         if 'contents' in args.keys():
             post['contents'] = args['contents']
         if 'tags' in args.keys():
             post['tags'] = list([b64decode(temp) \
                 for temp in args['tags'].split(':')])
         else:
             post['tags'] = []
         post = manager.update_post(post, id, username)
         return {'post': marshal(post, PostAPI.response_post_field)}
     else:
         abort(400)