summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMasayuki Igawa <mas-igawa@ut.jp.nec.com>2015-03-27 10:59:27 -0400
committerMasayuki Igawa <mas-igawa@ut.jp.nec.com>2015-03-27 14:52:02 -0400
commit88d5d612db06a808114d9430cb604337dbfb85ad (patch)
tree0428347a07344acafde570d8e8e9931c5a9eaa9e
parentc46441a0393df3960a2eeaf7e194431104438bf4 (diff)
downloadtempest-lib-88d5d612db06a808114d9430cb604337dbfb85ad.tar.gz
Add unit tests for properties of rest_client
This commit adds some unit tests for properties of rest_client. Change-Id: I5237f7140c6b6410564b0e5b1912ca667e7d2e29
-rw-r--r--tempest_lib/tests/fake_auth_provider.py10
-rw-r--r--tempest_lib/tests/test_rest_client.py41
2 files changed, 51 insertions, 0 deletions
diff --git a/tempest_lib/tests/fake_auth_provider.py b/tempest_lib/tests/fake_auth_provider.py
index bc68d26..3b4f060 100644
--- a/tempest_lib/tests/fake_auth_provider.py
+++ b/tempest_lib/tests/fake_auth_provider.py
@@ -16,5 +16,15 @@
class FakeAuthProvider(object):
+ def __init__(self, creds_dict={}):
+ self.credentials = FakeCredentials(creds_dict)
+
def auth_request(self, method, url, headers=None, body=None, filters=None):
return url, headers, body
+
+
+class FakeCredentials(object):
+
+ def __init__(self, creds_dict):
+ for key in creds_dict.keys():
+ setattr(self, key, creds_dict[key])
diff --git a/tempest_lib/tests/test_rest_client.py b/tempest_lib/tests/test_rest_client.py
index d585b88..364d765 100644
--- a/tempest_lib/tests/test_rest_client.py
+++ b/tempest_lib/tests/test_rest_client.py
@@ -438,6 +438,47 @@ class TestRestClientUtils(BaseRestClientTestClass):
'1234')
+class TestProperties(BaseRestClientTestClass):
+
+ def setUp(self):
+ self.fake_http = fake_http.fake_httplib2()
+ super(TestProperties, self).setUp()
+ creds_dict = {
+ 'username': 'test-user',
+ 'user_id': 'test-user_id',
+ 'tenant_name': 'test-tenant_name',
+ 'tenant_id': 'test-tenant_id',
+ 'password': 'test-password'
+ }
+ self.rest_client = rest_client.RestClient(
+ fake_auth_provider.FakeAuthProvider(creds_dict=creds_dict),
+ None, None)
+
+ def test_properties(self):
+ self.assertEqual('test-user', self.rest_client.user)
+ self.assertEqual('test-user_id', self.rest_client.user_id)
+ self.assertEqual('test-tenant_name', self.rest_client.tenant_name)
+ self.assertEqual('test-tenant_id', self.rest_client.tenant_id)
+ self.assertEqual('test-password', self.rest_client.password)
+
+ self.rest_client.api_version = 'v1'
+ expected = {'api_version': 'v1',
+ 'endpoint_type': 'publicURL',
+ 'region': None,
+ 'service': None,
+ 'skip_path': True}
+ self.rest_client.skip_path()
+ self.assertEqual(expected, self.rest_client.filters)
+
+ self.rest_client.reset_path()
+ self.rest_client.api_version = 'v1'
+ expected = {'api_version': 'v1',
+ 'endpoint_type': 'publicURL',
+ 'region': None,
+ 'service': None}
+ self.assertEqual(expected, self.rest_client.filters)
+
+
class TestExpectedSuccess(BaseRestClientTestClass):
def setUp(self):