Merge "Make test_ringbuilder less brittle"

This commit is contained in:
Jenkins 2016-06-09 18:46:29 +00:00 committed by Gerrit Code Review
commit 84a8465fc1

View File

@ -1925,14 +1925,18 @@ class TestCommands(unittest.TestCase, RunSwiftRingBuilderMixin):
mock_stdout = six.StringIO()
mock_stderr = six.StringIO()
argv = ["", "object.ring.gz"]
argv = ["", self.tmpfile, "rebalance", "3"],
self.assertSystemExit(EXIT_SUCCESS, ringbuilder.main, argv)
argv = ["", "%s.ring.gz" % self.tmpfile]
with mock.patch("sys.stdout", mock_stdout):
with mock.patch("sys.stderr", mock_stderr):
self.assertSystemExit(EXIT_ERROR, ringbuilder.main, argv)
expected = "Note: using object.builder instead of object.ring.gz " \
expected = "Note: using %s.builder instead of %s.ring.gz " \
"as builder file\n" \
"Ring Builder file does not exist: object.builder\n"
"Ring Builder file does not exist: %s.builder\n" % (
self.tmpfile, self.tmpfile, self.tmpfile)
self.assertEqual(expected, mock_stdout.getvalue())
def test_main_no_arguments(self):