Commit be08d441 authored by Ilias Tsitsimpis's avatar Ilias Tsitsimpis

astakosclient: Fix unittests

A new endpoint (astakos_oauth2) was added to Astakos service.
Add this endpoint to the astakosclient tests.
parent 05039b9d
...@@ -65,6 +65,7 @@ except ImportError: ...@@ -65,6 +65,7 @@ except ImportError:
auth_url = "https://example.org/identity/v2.0" auth_url = "https://example.org/identity/v2.0"
account_prefix = "/account_prefix" account_prefix = "/account_prefix"
ui_prefix = "/ui_prefix" ui_prefix = "/ui_prefix"
oauth2_prefix = "/oauth2"
api_tokens = "/identity/v2.0/tokens" api_tokens = "/identity/v2.0/tokens"
api_usercatalogs = join_urls(account_prefix, "user_catalogs") api_usercatalogs = join_urls(account_prefix, "user_catalogs")
api_resources = join_urls(account_prefix, "resources") api_resources = join_urls(account_prefix, "resources")
...@@ -97,15 +98,25 @@ resources = { ...@@ -97,15 +98,25 @@ resources = {
endpoints = { endpoints = {
"access": { "access": {
"serviceCatalog": [{ "serviceCatalog": [
"endpoints": [{"SNF:uiURL": join_urls("https://example.org/", {"endpoints": [{"SNF:uiURL": join_urls("https://example.org/",
ui_prefix), ui_prefix),
"publicURL": join_urls("https://example.org/", "publicURL": join_urls("https://example.org/",
account_prefix), account_prefix),
"region": "default", "region": "default",
"versionId": "v1.0"}], "versionId": "v1.0"}],
"name": "astakos_account", "name": "astakos_account",
"type": "account"}] "type": "account"
},
{"endpoints": [{"SNF:uiURL": join_urls("https://example.org/",
ui_prefix),
"publicURL": join_urls("https://example.org/",
oauth2_prefix),
"region": "default",
"versionId": "v1.0"}],
"name": "astakos_oauth2",
"type": "astakos_auth"
}]
} }
} }
...@@ -414,7 +425,7 @@ class TestCallAstakos(unittest.TestCase): ...@@ -414,7 +425,7 @@ class TestCallAstakos(unittest.TestCase):
"""Test cases for function _callAstakos""" """Test cases for function _callAstakos"""
# Patch astakosclient's _do_request function # Patch astakosclient's _do_request function
def setUp(self): def setUp(self): # noqa
astakosclient._do_request = _mock_request astakosclient._do_request = _mock_request
# ---------------------------------- # ----------------------------------
...@@ -556,7 +567,7 @@ class TestAuthenticate(unittest.TestCase): ...@@ -556,7 +567,7 @@ class TestAuthenticate(unittest.TestCase):
"""Test cases for function getUserInfo""" """Test cases for function getUserInfo"""
# Patch astakosclient's _do_request function # Patch astakosclient's _do_request function
def setUp(self): def setUp(self): # noqa
astakosclient._do_request = _mock_request astakosclient._do_request = _mock_request
# ---------------------------------- # ----------------------------------
...@@ -589,8 +600,8 @@ class TestAuthenticate(unittest.TestCase): ...@@ -589,8 +600,8 @@ class TestAuthenticate(unittest.TestCase):
try: try:
client = AstakosClient(token['id'], auth_url, use_pool=pool) client = AstakosClient(token['id'], auth_url, use_pool=pool)
auth_info = client.authenticate() auth_info = client.authenticate()
except: except Exception as err:
self.fail("Shouldn't raise an Exception") self.fail("Shouldn't raise an Exception: %s" % err)
self.assertEqual(endpoints_with_info, auth_info) self.assertEqual(endpoints_with_info, auth_info)
def test_auth_user(self): def test_auth_user(self):
...@@ -606,7 +617,7 @@ class TestDisplayNames(unittest.TestCase): ...@@ -606,7 +617,7 @@ class TestDisplayNames(unittest.TestCase):
"""Test cases for functions getDisplayNames/getDisplayName""" """Test cases for functions getDisplayNames/getDisplayName"""
# Patch astakosclient's _do_request function # Patch astakosclient's _do_request function
def setUp(self): def setUp(self): # noqa
astakosclient._do_request = _mock_request astakosclient._do_request = _mock_request
# ---------------------------------- # ----------------------------------
...@@ -657,7 +668,7 @@ class TestGetUUIDs(unittest.TestCase): ...@@ -657,7 +668,7 @@ class TestGetUUIDs(unittest.TestCase):
"""Test cases for functions getUUIDs/getUUID""" """Test cases for functions getUUIDs/getUUID"""
# Patch astakosclient's _do_request function # Patch astakosclient's _do_request function
def setUp(self): def setUp(self): # noqa
astakosclient._do_request = _mock_request astakosclient._do_request = _mock_request
# ---------------------------------- # ----------------------------------
...@@ -707,7 +718,7 @@ class TestResources(unittest.TestCase): ...@@ -707,7 +718,7 @@ class TestResources(unittest.TestCase):
"""Test cases for function get_resources""" """Test cases for function get_resources"""
# Patch astakosclient's _do_request function # Patch astakosclient's _do_request function
def setUp(self): def setUp(self): # noqa
astakosclient._do_request = _mock_request astakosclient._do_request = _mock_request
# ---------------------------------- # ----------------------------------
...@@ -726,7 +737,7 @@ class TestQuotas(unittest.TestCase): ...@@ -726,7 +737,7 @@ class TestQuotas(unittest.TestCase):
"""Test cases for function get_quotas""" """Test cases for function get_quotas"""
# Patch astakosclient's _do_request function # Patch astakosclient's _do_request function
def setUp(self): def setUp(self): # noqa
astakosclient._do_request = _mock_request astakosclient._do_request = _mock_request
# ---------------------------------- # ----------------------------------
...@@ -760,7 +771,7 @@ class TestCommissions(unittest.TestCase): ...@@ -760,7 +771,7 @@ class TestCommissions(unittest.TestCase):
"""Test cases for quota commissions""" """Test cases for quota commissions"""
# Patch astakosclient's _do_request function # Patch astakosclient's _do_request function
def setUp(self): def setUp(self): # noqa
astakosclient._do_request = _mock_request astakosclient._do_request = _mock_request
# ---------------------------------- # ----------------------------------
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment