def setUp(self): super(TestMovieHandler, self).setUp() # create several movies for i in range(3): movie = Movie(name="movie%i" % i, description="description%i" % i) movie.put() self.movie = movie.key() post_data = {"email": "*****@*****.**", "password": "******"} request = webapp2.Request.blank("/api/auth/login/", POST=post_data) response = request.get_response(main.app) self.jwt_token = response.headers["JWT"]
def post(self): logging.debug("MovieListHandler. POST. auth: {}".format( self.request.headers.get("Authorization"))) name = self.request.get("name") description = self.request.get("description") if not (name and description): json_response( self, {"message": "Name and description fields must be filled"}, status=400) return logging.debug( "MovieListHandler. POST. name: {}. description: {}. auth: {}". format(name, description, self.request.headers.get("Authorization"))) movie = Movie(name=name, description=description) movie.put() json_response(self, data=movie.to_dict(), status=201)