a few fixes to tests -- a lot more to be done

This commit is contained in:
John Dickinson 2014-09-13 17:39:46 -07:00
parent 3188967d26
commit f5234eed45
2 changed files with 14 additions and 12 deletions

View File

@ -23,7 +23,8 @@ from shutil import rmtree
from slogging import db_stats_collector from slogging import db_stats_collector
from tempfile import mkdtemp from tempfile import mkdtemp
from test_slogging.unit import FakeLogger from test_slogging.unit import FakeLogger
from swift.common.db import AccountBroker, ContainerBroker from swift.account.backend import AccountBroker
from swift.container.backend import ContainerBroker
from swift.common.utils import mkdirs from swift.common.utils import mkdirs

View File

@ -16,10 +16,11 @@
# TODO: Tests # TODO: Tests
import unittest import unittest
import webob
import tempfile import tempfile
import json import json
from swift.common import swob
from slogging import internal_proxy from slogging import internal_proxy
@ -58,7 +59,7 @@ class DumbApplication(object):
body = '' body = ''
else: else:
body = self.body body = self.body
resp = webob.Response(request=req, body=body, resp = swob.Response(request=req, body=body,
conditional_response=True) conditional_response=True)
try: try:
resp.status_int = self.status_codes.pop(0) resp.status_int = self.status_codes.pop(0)
@ -72,9 +73,9 @@ class DumbApplication(object):
class TestInternalProxy(unittest.TestCase): class TestInternalProxy(unittest.TestCase):
def test_webob_request_copy(self): def test_swob_request_copy(self):
req = webob.Request.blank('/') req = swob.Request.blank('/')
req2 = internal_proxy.webob_request_copy(req) req2 = internal_proxy.swob_request_copy(req)
self.assertEquals(req.path, req2.path) self.assertEquals(req.path, req2.path)
self.assertEquals(req.path_info, req2.path_info) self.assertEquals(req.path_info, req2.path_info)
self.assertFalse(req is req2) self.assertFalse(req is req2)
@ -86,8 +87,8 @@ class TestInternalProxy(unittest.TestCase):
internal_proxy.Application = DumbApplicationFactory( internal_proxy.Application = DumbApplicationFactory(
status_codes) status_codes)
p = internal_proxy.InternalProxy() p = internal_proxy.InternalProxy()
req = webob.Request.blank('/') req = swob.Request.blank('/')
orig_req = internal_proxy.webob_request_copy(req) orig_req = internal_proxy.swob_request_copy(req)
resp = p._handle_request(req) resp = p._handle_request(req)
self.assertEquals(req.path_info, orig_req.path_info) self.assertEquals(req.path_info, orig_req.path_info)
@ -96,8 +97,8 @@ class TestInternalProxy(unittest.TestCase):
internal_proxy.Application = DumbApplicationFactory( internal_proxy.Application = DumbApplicationFactory(
status_codes) status_codes)
p = internal_proxy.InternalProxy(retries=3) p = internal_proxy.InternalProxy(retries=3)
req = webob.Request.blank('/') req = swob.Request.blank('/')
orig_req = internal_proxy.webob_request_copy(req) orig_req = internal_proxy.swob_request_copy(req)
resp = p._handle_request(req) resp = p._handle_request(req)
self.assertEquals(req.path_info, orig_req.path_info) self.assertEquals(req.path_info, orig_req.path_info)
self.assertEquals(p.upload_app.call_count, 2) self.assertEquals(p.upload_app.call_count, 2)
@ -126,8 +127,8 @@ class TestInternalProxy(unittest.TestCase):
internal_proxy.Application = DumbApplicationFactory( internal_proxy.Application = DumbApplicationFactory(
status_codes) status_codes)
p = internal_proxy.InternalProxy(retries=3) p = internal_proxy.InternalProxy(retries=3)
req = webob.Request.blank('/') req = swob.Request.blank('/')
orig_req = internal_proxy.webob_request_copy(req) orig_req = internal_proxy.swob_request_copy(req)
resp = p._handle_request(req) resp = p._handle_request(req)
self.assertEquals(req.path_info, orig_req.path_info) self.assertEquals(req.path_info, orig_req.path_info)
self.assertEquals(p.upload_app.call_count, 3) self.assertEquals(p.upload_app.call_count, 3)