def test_process_path(self): path = '/countries/bra' value = args.process_path(path, 'iso') self.assertEqual({'iso': 'bra'}, value) path = '/countries/bra/123' value = args.process_path(path, 'id1') self.assertEqual({'iso': 'bra', 'id1': '123'}, value)
def get(self): try: path = self.request.path.strip("/") rtype = _classify_request(path) # Unsupported dataset or reqest type if not rtype: self.error(404) return # Return API meta if path == 'countries': action, data = self._action_data() else: path_args = args.process_path(path, rtype) action, data = self._action_data(path_args) self.complete(action, data) except Exception, e: logging.exception(e) self.write_error(400, e.message) self.write(json.dumps(META, sort_keys=True))