def get(self): """GET /: Retrieve all todos""" self.response.headers = initialize_headers(self.response.headers, 'GET') qry = TodoModel.query().fetch() all_todos = serialize_data(qry) self.response.out.write(json.dumps(all_todos, sort_keys=True, indent=4))
def test_insert(self): todoApi = TodoApi() #gets an instance of the message that is generated dynamically by the library endpoints_proto_datastore request = todoApi.TodoInsert.remote.request_type() request.title = self.TITLE todoApi.TodoInsert(request) query = TodoModel.query().fetch() self.assertEqual(1, len(query)) result = query[0] self.assertEquals(self.TITLE, result.title) self.assertEquals(self.IS_COMPLETED, result.completed)
def get(self): """GET /: Retrieve all todos""" try: qry = TodoModel.query().fetch() all_todos = serialize_data(qry) self.response.headers['Content-Type'] = 'text/plain' self.response.write(json.dumps(all_todos, sort_keys=True, indent=4)) except: # TODO: Improve this error raise Exception("Error: could not complete request")