Merge "Fix test_location unit test"
This commit is contained in:
commit
58ded99729
@ -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()
|
||||
|
Loading…
Reference in New Issue
Block a user