Commit 4359b73c by Bach Dániel

dashboard: fix test

parent 01816dc9
...@@ -497,18 +497,19 @@ class VmDetailTest(LoginMixin, TestCase): ...@@ -497,18 +497,19 @@ class VmDetailTest(LoginMixin, TestCase):
def test_permitted_wake_up(self): def test_permitted_wake_up(self):
c = Client() c = Client()
self.login(c, "user2") self.login(c, "user2")
with patch.object(Instance, 'wake_up_async') as new_wake_up: with patch.object(Instance, 'select_node', return_value=None):
with patch('vm.tasks.vm_tasks.wake_up.apply_async') as wuaa: with patch.object(Instance, 'wake_up_async') as new_wake_up:
inst = Instance.objects.get(pk=1) with patch('vm.tasks.vm_tasks.wake_up.apply_async') as wuaa:
new_wake_up.side_effect = inst.wake_up inst = Instance.objects.get(pk=1)
inst.get_remote_queue_name = Mock(return_value='test') new_wake_up.side_effect = inst.wake_up
inst.manual_state_change('SUSPENDED') inst.get_remote_queue_name = Mock(return_value='test')
inst.set_level(self.u2, 'owner') inst.manual_state_change('SUSPENDED')
response = c.post("/dashboard/vm/1/", {'wake_up': True}) inst.set_level(self.u2, 'owner')
self.assertEqual(response.status_code, 302) response = c.post("/dashboard/vm/1/", {'wake_up': True})
self.assertEqual(inst.status, 'RUNNING') self.assertEqual(response.status_code, 302)
assert new_wake_up.called self.assertEqual(inst.status, 'RUNNING')
assert wuaa.called assert new_wake_up.called
assert wuaa.called
def test_unpermitted_wake_up(self): def test_unpermitted_wake_up(self):
c = Client() c = Client()
......
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