Merge "Add unit case"
This commit is contained in:
commit
db5fd6470a
@ -171,7 +171,7 @@ class TestAccountController(unittest.TestCase):
|
||||
resp = req.get_response(self.account_controller)
|
||||
self.assertEqual(resp.status_int, 507)
|
||||
|
||||
def test_REPLICATE_works(self):
|
||||
def test_REPLICATE_rsync_then_merge_works(self):
|
||||
mkdirs(os.path.join(self.testdir, 'sda1', 'account', 'p', 'a', 'a'))
|
||||
db_file = os.path.join(self.testdir, 'sda1',
|
||||
storage_directory('account', 'p', 'a'),
|
||||
@ -192,6 +192,32 @@ class TestAccountController(unittest.TestCase):
|
||||
resp = req.get_response(self.controller)
|
||||
self.assertEqual(resp.status_int, 204)
|
||||
|
||||
def test_REPLICATE_complete_rsync_works(self):
|
||||
mkdirs(os.path.join(self.testdir, 'sda1', 'account', 'p', 'a', 'a'))
|
||||
db_file = os.path.join(self.testdir, 'sda1',
|
||||
storage_directory('account', 'p', 'a'),
|
||||
'a' + '.db')
|
||||
open(db_file, 'w')
|
||||
|
||||
def fake_complete_rsync(self, drive, db_file, args):
|
||||
return HTTPNoContent()
|
||||
# check complete_rsync
|
||||
with mock.patch("swift.common.db_replicator.ReplicatorRpc."
|
||||
"complete_rsync", fake_complete_rsync):
|
||||
req = Request.blank('/sda1/p/a/',
|
||||
environ={'REQUEST_METHOD': 'REPLICATE'},
|
||||
headers={})
|
||||
json_string = '["complete_rsync", "a.db"]'
|
||||
inbuf = WsgiBytesIO(json_string)
|
||||
req.environ['wsgi.input'] = inbuf
|
||||
resp = req.get_response(self.controller)
|
||||
self.assertEqual(resp.status_int, 204)
|
||||
|
||||
def test_REPLICATE_value_error_works(self):
|
||||
req = Request.blank('/sda1/p/a/',
|
||||
environ={'REQUEST_METHOD': 'REPLICATE'},
|
||||
headers={})
|
||||
|
||||
# check valuerror
|
||||
wsgi_input_valuerror = '["sync" : sync, "-1"]'
|
||||
inbuf1 = WsgiBytesIO(wsgi_input_valuerror)
|
||||
|
@ -1285,7 +1285,7 @@ class TestContainerController(unittest.TestCase):
|
||||
resp = req.get_response(self.container_controller)
|
||||
self.assertEqual(resp.status_int, 507)
|
||||
|
||||
def test_REPLICATE_works(self):
|
||||
def test_REPLICATE_rsync_then_merge_works(self):
|
||||
mkdirs(os.path.join(self.testdir, 'sda1', 'containers', 'p', 'a', 'a'))
|
||||
db_file = os.path.join(self.testdir, 'sda1',
|
||||
storage_directory('containers', 'p', 'a'),
|
||||
@ -1306,6 +1306,30 @@ class TestContainerController(unittest.TestCase):
|
||||
resp = req.get_response(self.controller)
|
||||
self.assertEqual(resp.status_int, 204)
|
||||
|
||||
def test_REPLICATE_complete_rsync_works(self):
|
||||
mkdirs(os.path.join(self.testdir, 'sda1', 'containers', 'p', 'a', 'a'))
|
||||
db_file = os.path.join(self.testdir, 'sda1',
|
||||
storage_directory('containers', 'p', 'a'),
|
||||
'a' + '.db')
|
||||
open(db_file, 'w')
|
||||
|
||||
def fake_complete_rsync(self, drive, db_file, args):
|
||||
return HTTPNoContent()
|
||||
with mock.patch("swift.container.replicator.ContainerReplicatorRpc."
|
||||
"complete_rsync", fake_complete_rsync):
|
||||
req = Request.blank('/sda1/p/a/',
|
||||
environ={'REQUEST_METHOD': 'REPLICATE'},
|
||||
headers={})
|
||||
json_string = '["complete_rsync", "a.db"]'
|
||||
inbuf = WsgiBytesIO(json_string)
|
||||
req.environ['wsgi.input'] = inbuf
|
||||
resp = req.get_response(self.controller)
|
||||
self.assertEqual(resp.status_int, 204)
|
||||
|
||||
def test_REPLICATE_value_error_works(self):
|
||||
req = Request.blank('/sda1/p/a/',
|
||||
environ={'REQUEST_METHOD': 'REPLICATE'},
|
||||
headers={})
|
||||
# check valuerror
|
||||
wsgi_input_valuerror = '["sync" : sync, "-1"]'
|
||||
inbuf1 = WsgiBytesIO(wsgi_input_valuerror)
|
||||
|
Loading…
Reference in New Issue
Block a user