Rephrase astakos client and wip clients code
authorStavros Sachtouris <saxtouri@admin.grnet.gr>
Fri, 15 Mar 2013 08:45:07 +0000 (10:45 +0200)
committerStavros Sachtouris <saxtouri@admin.grnet.gr>
Fri, 15 Mar 2013 08:45:07 +0000 (10:45 +0200)
kamaki/clients/astakos/test.py
kamaki/clients/connection/errors.py
kamaki/clients/pithos/__init__.py

index b343c3b..0076013 100644 (file)
@@ -31,7 +31,7 @@
 # interpreted as representing official policies, either expressed
 # or implied, of GRNET S.A.
 
-from mock import patch
+from mock import patch, call
 
 from unittest import TestCase
 from kamaki.clients.astakos import AstakosClient
@@ -66,7 +66,7 @@ class FR(object):
     def release(self):
         pass
 
-khttp = 'kamaki.clients.connection.kamakicon.KamakiHTTPConnection'
+astakos_pkg = 'kamaki.clients.astakos.AstakosClient'
 
 
 class Astakos(TestCase):
@@ -81,16 +81,15 @@ class Astakos(TestCase):
     def tearDown(self):
         FR.json = example
 
-    @patch('%s.perform_request' % khttp, return_value=FR())
-    def _authenticate(self, PR):
+    @patch('%s.get' % astakos_pkg, return_value=FR())
+    def _authenticate(self, get):
         r = self.client.authenticate()
+        self.assertEqual(get.mock_calls[-1], call('/im/authenticate'))
         self.cached = True
         return r
 
     def test_authenticate(self):
         r = self._authenticate()
-        self.assertEqual(self.client.http_client.url, self.url)
-        self.assertEqual(self.client.http_client.path, '/im/authenticate')
         for term, val in example.items():
             self.assertTrue(term in r)
             self.assertEqual(val, r[term])
index 7e916d8..5723ca0 100644 (file)
 
 
 class KamakiConnectionError(Exception):
-    errno = None
 
     def __init__(self, message, errno=None):
         super(KamakiConnectionError, self).__init__(message)
-        if errno:
-            self.errno = errno
+        self.errno = errno if errno else 0
 
 
 class KamakiResponseError(Exception):
-    errno = None
 
     def __init__(self, message, errno=None):
         super(KamakiResponseError, self).__init__(message)
-        if errno:
-            self.errno = errno
+        self.errno = errno if errno else 0
index 0cc0cd5..a9df347 100644 (file)
@@ -68,8 +68,6 @@ def _range_up(start, end, a_range):
 class PithosClient(PithosRestAPI):
     """GRNet Pithos API client"""
 
-    _thread_exceptions = []
-
     def __init__(self, base_url, token, account=None, container=None):
         super(PithosClient, self).__init__(base_url, token, account, container)