Revision ae4585f5
b/kamaki/clients/astakos/test.py | ||
---|---|---|
31 | 31 |
# interpreted as representing official policies, either expressed |
32 | 32 |
# or implied, of GRNET S.A. |
33 | 33 |
|
34 |
from mock import patch |
|
34 |
from mock import patch, call
|
|
35 | 35 |
|
36 | 36 |
from unittest import TestCase |
37 | 37 |
from kamaki.clients.astakos import AstakosClient |
... | ... | |
66 | 66 |
def release(self): |
67 | 67 |
pass |
68 | 68 |
|
69 |
khttp = 'kamaki.clients.connection.kamakicon.KamakiHTTPConnection'
|
|
69 |
astakos_pkg = 'kamaki.clients.astakos.AstakosClient'
|
|
70 | 70 |
|
71 | 71 |
|
72 | 72 |
class Astakos(TestCase): |
... | ... | |
81 | 81 |
def tearDown(self): |
82 | 82 |
FR.json = example |
83 | 83 |
|
84 |
@patch('%s.perform_request' % khttp, return_value=FR())
|
|
85 |
def _authenticate(self, PR):
|
|
84 |
@patch('%s.get' % astakos_pkg, return_value=FR())
|
|
85 |
def _authenticate(self, get):
|
|
86 | 86 |
r = self.client.authenticate() |
87 |
self.assertEqual(get.mock_calls[-1], call('/im/authenticate')) |
|
87 | 88 |
self.cached = True |
88 | 89 |
return r |
89 | 90 |
|
90 | 91 |
def test_authenticate(self): |
91 | 92 |
r = self._authenticate() |
92 |
self.assertEqual(self.client.http_client.url, self.url) |
|
93 |
self.assertEqual(self.client.http_client.path, '/im/authenticate') |
|
94 | 93 |
for term, val in example.items(): |
95 | 94 |
self.assertTrue(term in r) |
96 | 95 |
self.assertEqual(val, r[term]) |
b/kamaki/clients/connection/errors.py | ||
---|---|---|
33 | 33 |
|
34 | 34 |
|
35 | 35 |
class KamakiConnectionError(Exception): |
36 |
errno = None |
|
37 | 36 |
|
38 | 37 |
def __init__(self, message, errno=None): |
39 | 38 |
super(KamakiConnectionError, self).__init__(message) |
40 |
if errno: |
|
41 |
self.errno = errno |
|
39 |
self.errno = errno if errno else 0 |
|
42 | 40 |
|
43 | 41 |
|
44 | 42 |
class KamakiResponseError(Exception): |
45 |
errno = None |
|
46 | 43 |
|
47 | 44 |
def __init__(self, message, errno=None): |
48 | 45 |
super(KamakiResponseError, self).__init__(message) |
49 |
if errno: |
|
50 |
self.errno = errno |
|
46 |
self.errno = errno if errno else 0 |
b/kamaki/clients/pithos/__init__.py | ||
---|---|---|
68 | 68 |
class PithosClient(PithosRestAPI): |
69 | 69 |
"""GRNet Pithos API client""" |
70 | 70 |
|
71 |
_thread_exceptions = [] |
|
72 |
|
|
73 | 71 |
def __init__(self, base_url, token, account=None, container=None): |
74 | 72 |
super(PithosClient, self).__init__(base_url, token, account, container) |
75 | 73 |
|
Also available in: Unified diff