You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@libcloud.apache.org by to...@apache.org on 2011/05/21 15:32:05 UTC
svn commit: r1125696 - in /incubator/libcloud/trunk/test: __init__.py
loadbalancer/test_gogrid.py
Author: tomaz
Date: Sat May 21 13:32:05 2011
New Revision: 1125696
URL: http://svn.apache.org/viewvc?rev=1125696&view=rev
Log:
Add a new MockHttpTestCase class which behaves the same as the base MockHttp class, but you can also use assert methods if you class inherits from this one.
Modified:
incubator/libcloud/trunk/test/__init__.py
incubator/libcloud/trunk/test/loadbalancer/test_gogrid.py
Modified: incubator/libcloud/trunk/test/__init__.py
URL: http://svn.apache.org/viewvc/incubator/libcloud/trunk/test/__init__.py?rev=1125696&r1=1125695&r2=1125696&view=diff
==============================================================================
--- incubator/libcloud/trunk/test/__init__.py (original)
+++ incubator/libcloud/trunk/test/__init__.py Sat May 21 13:32:05 2011
@@ -12,8 +12,10 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
+
import httplib
import random
+import unittest
from cStringIO import StringIO
from urllib2 import urlparse
@@ -154,6 +156,18 @@ class MockHttp(BaseMockHttpObject):
return (httplib.FORBIDDEN, 'Oh Noes!', {'X-Foo': 'fail'},
httplib.responses[httplib.FORBIDDEN])
+class MockHttpTestCase(MockHttp, unittest.TestCase):
+ # Same as the MockHttp class, but you can also use assertions in the
+ # classes which inherit from this one.
+ def __init__(self, *args, **kwargs):
+ unittest.TestCase.__init__(self)
+
+ if kwargs.get('host', None) and kwargs.get('port', None):
+ MockHttp.__init__(self, *args, **kwargs)
+
+ def runTest(self):
+ pass
+
class StorageMockHttp(MockHttp):
def putrequest(self, method, action):
pass
@@ -167,7 +181,6 @@ class StorageMockHttp(MockHttp):
def send(self, data):
pass
-
class MockRawResponse(BaseMockHttpObject):
"""
Mock RawResponse object suitable for testing.
Modified: incubator/libcloud/trunk/test/loadbalancer/test_gogrid.py
URL: http://svn.apache.org/viewvc/incubator/libcloud/trunk/test/loadbalancer/test_gogrid.py?rev=1125696&r1=1125695&r2=1125696&view=diff
==============================================================================
--- incubator/libcloud/trunk/test/loadbalancer/test_gogrid.py (original)
+++ incubator/libcloud/trunk/test/loadbalancer/test_gogrid.py Sat May 21 13:32:05 2011
@@ -7,7 +7,7 @@ from urlparse import urlparse, parse_qsl
from libcloud.loadbalancer.base import LoadBalancer, Member, Algorithm
from libcloud.loadbalancer.drivers.gogrid import GoGridLBDriver
-from test import MockHttp, MockRawResponse
+from test import MockHttpTestCase
from test.file_fixtures import LoadBalancerFileFixtures
class GoGridTests(unittest.TestCase):
@@ -84,20 +84,9 @@ class GoGridTests(unittest.TestCase):
self.assertTrue(ret)
-class GoGridLBMockHttp(MockHttp, unittest.TestCase):
+class GoGridLBMockHttp(MockHttpTestCase):
fixtures = LoadBalancerFileFixtures('gogrid')
- def __init__(self, *args, **kwargs):
- unittest.TestCase.__init__(self)
-
- if kwargs.get('host', None) and kwargs.get('port', None):
- MockHttp.__init__(self, *args, **kwargs)
-
- def runTest(self):
- # @TODO: Add a new base MockHttpTestCase class and add this method and
- # constructor there
- pass
-
def _api_grid_loadbalancer_list(self, method, url, body, headers):
body = self.fixtures.load('loadbalancer_list.json')
return (httplib.OK, body, {}, httplib.responses[httplib.OK])