Merge "Fix test_location unit test"

This commit is contained in:
Jenkins 2014-12-02 06:28:04 +00:00 committed by Gerrit Code Review
commit 58ded99729

View File

@ -19,20 +19,40 @@ from swift.common.swob import Request
from swift3.test.unit import Swift3TestCase
from swift3.etree import fromstring
from swift3.cfg import CONF
class TestSwift3Location(Swift3TestCase):
def setUp(self):
super(TestSwift3Location, self).setUp()
# allow to change location config in test code
self.orig_loc = CONF.location
def tearDown(self):
CONF.location = self.orig_loc
def test_object_location(self):
req = Request.blank('/bucket/object?location',
req = Request.blank('/bucket?location',
environ={'REQUEST_METHOD': 'GET'},
headers={'Authorization': 'AWS test:tester:hmac'})
status, headers, body = self.call_swift3(req)
self.assertEquals(status.split()[0], '200')
fromstring(body, 'LocationConstraint')
elem = fromstring(body, 'LocationConstraint')
location = elem.text
self.assertEquals(location, None)
def test_object_location_setting_as_us_west_1(self):
CONF.location = 'us-west-1'
req = Request.blank('/bucket?location',
environ={'REQUEST_METHOD': 'GET'},
headers={'Authorization': 'AWS test:tester:hmac'})
status, headers, body = self.call_swift3(req)
self.assertEquals(status.split()[0], '200')
elem = fromstring(body, 'LocationConstraint')
location = elem.text
self.assertEquals(location, 'us-west-1')
if __name__ == '__main__':
unittest.main()