add __str__ function to RestClient class
Most tempest tests are based on restfull http call.
Enable to easily explore the state of client object
would be good for trouble shooting.
Thus, I would suggest to implement __str__ function for RestClient class.
Closes-Bug: #1227474
Change-Id: If06dfc648a7458133e4f196bdca299f9531738b1
diff --git a/tempest/common/rest_client.py b/tempest/common/rest_client.py
index 81393a9..fe332e9 100644
--- a/tempest/common/rest_client.py
+++ b/tempest/common/rest_client.py
@@ -77,6 +77,21 @@
self.http_obj = http.ClosingHttp(
disable_ssl_certificate_validation=dscv)
+ def __str__(self):
+ STRING_LIMIT = 80
+ str_format = ("config:%s, user:%s, password:%s, "
+ "auth_url:%s, tenant_name:%s, auth_version:%s, "
+ "service:%s, base_url:%s, region:%s, "
+ "endpoint_url:%s, build_interval:%s, build_timeout:%s"
+ "\ntoken:%s..., \nheaders:%s...")
+ return str_format % (self.config, self.user, self.password,
+ self.auth_url, self.tenant_name,
+ self.auth_version, self.service,
+ self.base_url, self.region, self.endpoint_url,
+ self.build_interval, self.build_timeout,
+ str(self.token)[0:STRING_LIMIT],
+ str(self.headers)[0:STRING_LIMIT])
+
def _set_auth(self):
"""
Sets the token and base_url used in requests based on the strategy type