4 from six.moves.urllib import parse
6 from opnfv_testapi.resources import handlers
9 class BaseHandler(handlers.GenericApiHandler):
10 def __init__(self, application, request, **kwargs):
11 super(BaseHandler, self).__init__(application, request, **kwargs)
14 def set_cookies(self, cookies):
15 for cookie_n, cookie_v in cookies:
16 self.set_secure_cookie(cookie_n, cookie_v)
19 def get_token(length=30):
20 """Get random token."""
21 return ''.join(random.choice(string.ascii_lowercase)
22 for i in range(length))
25 def set_query_params(url, params):
26 """Set params in given query."""
27 url_parts = parse.urlparse(url)
28 url = parse.urlunparse((
33 parse.urlencode(params),