def test_create_new_post(self, mocked_create_post): author = User("*****@*****.**", 123123, "test", "test", "test", 1, "test", None) post_body = "Test test test" post_privacy = POST_PRIVACY.PUBLIC test_loc = Location("Test", 1.0, 1.0) post_service.create_new_post(author, post_body, post_privacy, test_loc) new_post = mocked_create_post.call_args[0][0] self.assertEqual(new_post.author_id, author.user_id) self.assertEqual(new_post.body, post_body) self.assertEqual(new_post.privacy, post_privacy) self.assertEqual(new_post.location.city, test_loc.city)
def create_posts(): current_user = g.user current_location = g.user_location body = request.form['post-body'] privacy = request.form['privacy'] if(len(body) < MINIMUM_POST_BODY_LENGTH): return { "error" : True, "message" : "Please make your post greater than " + str(MINIMUM_POST_BODY_LENGTH) + " characters" } else: new_post = post_service.create_new_post(current_user, body, privacy, current_location) result_json_dict = { "error" : False, "result" : new_post.to_json_dict() } return result_json_dict