Add unit tests for properties of rest_client

This commit adds some unit tests for properties of rest_client.

Change-Id: I5237f7140c6b6410564b0e5b1912ca667e7d2e29
This commit is contained in:
Masayuki Igawa
2015-03-27 10:59:27 -04:00
parent c46441a039
commit 88d5d612db
2 changed files with 51 additions and 0 deletions

View File

@@ -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])

View File

@@ -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):