Fix failing tests in gates

This tests actually were wrong since begging. Cause __lt__ and __gt__
stuff works only in case of instance of classes.
So I really don't know why this worked at all

Add any_order=True to some of assert_has_calls

Closes-Bug: #1358744

Change-Id: Ia699611c14e25b4a1d4592304192c444ba26f853
This commit is contained in:
Boris Pavlovic 2014-08-21 19:34:22 +04:00
parent bd009a5c1c
commit 6ad67148ec
2 changed files with 39 additions and 17 deletions

View File

@ -116,18 +116,33 @@ class BaseContextTestCase(test.TestCase):
self.assertNotEqual(cls.get_name(), "base", str(cls))
def test_lt(self):
self.assertTrue(base.Context < fakes.FakeContext)
self.assertFalse(fakes.FakeContext < base.Context)
self.assertFalse(base.Context < base.Context)
class FakeLowerContext(fakes.FakeContext):
__ctx_order__ = fakes.FakeContext.get_order() - 1
ctx = mock.MagicMock()
self.assertTrue(FakeLowerContext(ctx) < fakes.FakeContext(ctx))
self.assertFalse(fakes.FakeContext(ctx) < FakeLowerContext(ctx))
self.assertFalse(fakes.FakeContext(ctx) < fakes.FakeContext(ctx))
def test_gt(self):
self.assertTrue(fakes.FakeContext > base.Context)
self.assertFalse(base.Context > fakes.FakeContext)
self.assertFalse(base.Context > base.Context)
class FakeBiggerContext(fakes.FakeContext):
__ctx_order__ = fakes.FakeContext.get_order() + 1
ctx = mock.MagicMock()
self.assertTrue(FakeBiggerContext(ctx) > fakes.FakeContext(ctx))
self.assertFalse(fakes.FakeContext(ctx) > FakeBiggerContext(ctx))
self.assertFalse(fakes.FakeContext(ctx) > fakes.FakeContext(ctx))
def test_eq(self):
self.assertFalse(base.Context == fakes.FakeContext)
self.assertTrue(base.Context == base.Context)
class FakeOtherContext(fakes.FakeContext):
__ctx_order__ = fakes.FakeContext.get_order() + 1
ctx = mock.MagicMock()
self.assertFalse(FakeOtherContext(ctx) == fakes.FakeContext(ctx))
self.assertTrue(FakeOtherContext(ctx) == FakeOtherContext(ctx))
class ContextManagerTestCase(test.TestCase):
@ -192,12 +207,14 @@ class ContextManagerTestCase(test.TestCase):
result = manager.setup()
self.assertEqual(result, ctx_object)
mock_get_by_name.assert_has_calls([mock.call("a"), mock.call("b")])
mock_get_by_name.assert_has_calls([mock.call("a"), mock.call("b")],
any_order=True)
mock_context.assert_has_calls([mock.call(ctx_object),
mock.call(ctx_object)])
mock.call(ctx_object)], any_order=True)
self.assertEqual([mock_context(), mock_context()], manager._visited)
mock_context.return_value.assert_has_calls([mock.call.setup(),
mock.call.setup()])
mock.call.setup()],
any_order=True)
@mock.patch("rally.benchmark.context.base.Context.get_by_name")
def test_cleanup(self, mock_get_by_name):
@ -207,11 +224,13 @@ class ContextManagerTestCase(test.TestCase):
manager = base.ContextManager(ctx_object)
manager.cleanup()
mock_get_by_name.assert_has_calls([mock.call("a"), mock.call("b")])
mock_get_by_name.assert_has_calls([mock.call("a"), mock.call("b")],
any_order=True)
mock_context.assert_has_calls([mock.call(ctx_object),
mock.call(ctx_object)])
mock.call(ctx_object)], any_order=True)
mock_context.return_value.assert_has_calls([mock.call.cleanup(),
mock.call.cleanup()])
mock.call.cleanup()],
any_order=True)
@mock.patch("rally.benchmark.context.base.Context.get_by_name")
def test_cleanp_exception(self, mock_get_by_name):
@ -222,11 +241,13 @@ class ContextManagerTestCase(test.TestCase):
manager = base.ContextManager(ctx_object)
manager.cleanup()
mock_get_by_name.assert_has_calls([mock.call("a"), mock.call("b")])
mock_get_by_name.assert_has_calls([mock.call("a"), mock.call("b")],
any_order=True)
mock_context.assert_has_calls([mock.call(ctx_object),
mock.call(ctx_object)])
mock.call(ctx_object)], any_order=True)
mock_context.return_value.assert_has_calls([mock.call.cleanup(),
mock.call.cleanup()])
mock.call.cleanup()],
any_order=True)
@mock.patch("rally.benchmark.context.base.ContextManager.cleanup")
@mock.patch("rally.benchmark.context.base.ContextManager.setup")

View File

@ -8,6 +8,7 @@ setenv = VIRTUAL_ENV={envdir}
LANG=en_US.UTF-8
LANGUAGE=en_US:en
LC_ALL=C
PYTHONHASHSEED=0
deps = -r{toxinidir}/requirements.txt
-r{toxinidir}/test-requirements.txt
install_command = pip install -U {opts} {packages}