def test_create_new_reply(self, mocked_create_reply): author = User("*****@*****.**", 123123, "test", "test", "test", 1, "test", None) reply_body = "Test test test" reply_parent_id = 1 reply_privacy = POST_PRIVACY.PUBLIC reply_loc = Location("Test", 1.0, 1.0) post_service.create_new_reply(author, reply_body, reply_parent_id, reply_loc, reply_privacy) new_reply = mocked_create_reply.call_args[0][0] self.assertEqual(new_reply.author_id, author.user_id) self.assertEqual(new_reply.reply_body, reply_body) self.assertEqual(new_reply.privacy, reply_privacy) self.assertEqual(new_reply.city, reply_loc.city)
def create_reply(post_id): current_user = g.user current_location = g.user_location body = request.form['reply-body'] privacy = request.form['privacy'] new_reply = post_service.create_new_reply(current_user, body, post_id, current_location, privacy) updated_post = post_service.get_post_by_id(current_user.user_id, post_id) notification_service.create_notification_for_user(updated_post.author_id, NotificationType.REPLIED, post_id, current_user.user_id) return { "error" : False, "reply" : new_reply.to_json_dict(), "updated_post" : updated_post.to_json_dict() }