Commit 3f60bd73 by Őry Máté

vm: fix tests

MagicMock.__init__'s name parameter doesnt set the name attribute.
parent 3c6a1b3e
...@@ -370,10 +370,10 @@ class InstanceActivityTestCase(TestCase): ...@@ -370,10 +370,10 @@ class InstanceActivityTestCase(TestCase):
subact.__enter__.assert_called() subact.__enter__.assert_called()
def test_flush(self): def test_flush(self):
insts = [MagicMock(spec=Instance, migrate=MagicMock(), name="1"), insts = [MagicMock(spec=Instance, migrate=MagicMock()),
MagicMock(spec=Instance, migrate=MagicMock(), name="2")] MagicMock(spec=Instance, migrate=MagicMock())]
print insts[0].name insts[0].name = insts[1].name = "x"
node = MagicMock(spec=Node, enabled=True, name="node1") node = MagicMock(spec=Node, enabled=True)
node.instance_set.all.return_value = insts node.instance_set.all.return_value = insts
user = MagicMock(spec=User) user = MagicMock(spec=User)
user.is_superuser = MagicMock(return_value=True) user.is_superuser = MagicMock(return_value=True)
...@@ -391,8 +391,9 @@ class InstanceActivityTestCase(TestCase): ...@@ -391,8 +391,9 @@ class InstanceActivityTestCase(TestCase):
user.is_superuser.assert_called() user.is_superuser.assert_called()
def test_flush_disabled_wo_user(self): def test_flush_disabled_wo_user(self):
insts = [MagicMock(spec=Instance, migrate=MagicMock(), name="1"), insts = [MagicMock(spec=Instance, migrate=MagicMock()),
MagicMock(spec=Instance, migrate=MagicMock(), name="2")] MagicMock(spec=Instance, migrate=MagicMock())]
insts[0].name = insts[1].name = "x"
node = MagicMock(spec=Node, enabled=False) node = MagicMock(spec=Node, enabled=False)
node.instance_set.all.return_value = insts node.instance_set.all.return_value = insts
flush_op = FlushOperation(node) flush_op = FlushOperation(node)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment