Commit 404d3603 by Őry Máté

dashboard: update tests

parent e7d82c3f
...@@ -493,9 +493,11 @@ class VmDetailTest(LoginMixin, TestCase): ...@@ -493,9 +493,11 @@ class VmDetailTest(LoginMixin, TestCase):
mock_method.side_effect = inst.wake_up mock_method.side_effect = inst.wake_up
inst.manual_state_change('RUNNING') inst.manual_state_change('RUNNING')
inst.set_level(self.u2, 'owner') inst.set_level(self.u2, 'owner')
self.assertRaises(inst.WrongStateError, c.post, with patch('dashboard.views.messages') as msg:
"/dashboard/vm/1/", {'wake_up': True}) c.post("/dashboard/vm/1/op/wake_up/")
self.assertEqual(inst.status, 'RUNNING') assert msg.error.called
inst = Instance.objects.get(pk=1)
self.assertEqual(inst.status, 'RUNNING') # mocked anyway
assert mock_method.called assert mock_method.called
def test_permitted_wake_up(self): def test_permitted_wake_up(self):
...@@ -509,7 +511,9 @@ class VmDetailTest(LoginMixin, TestCase): ...@@ -509,7 +511,9 @@ class VmDetailTest(LoginMixin, TestCase):
inst.get_remote_queue_name = Mock(return_value='test') inst.get_remote_queue_name = Mock(return_value='test')
inst.manual_state_change('SUSPENDED') inst.manual_state_change('SUSPENDED')
inst.set_level(self.u2, 'owner') inst.set_level(self.u2, 'owner')
response = c.post("/dashboard/vm/1/", {'wake_up': True}) with patch('dashboard.views.messages') as msg:
response = c.post("/dashboard/vm/1/op/wake_up/")
assert not msg.error.called
self.assertEqual(response.status_code, 302) self.assertEqual(response.status_code, 302)
self.assertEqual(inst.status, 'RUNNING') self.assertEqual(inst.status, 'RUNNING')
assert new_wake_up.called assert new_wake_up.called
...@@ -521,8 +525,11 @@ class VmDetailTest(LoginMixin, TestCase): ...@@ -521,8 +525,11 @@ class VmDetailTest(LoginMixin, TestCase):
inst = Instance.objects.get(pk=1) inst = Instance.objects.get(pk=1)
inst.manual_state_change('SUSPENDED') inst.manual_state_change('SUSPENDED')
inst.set_level(self.u2, 'user') inst.set_level(self.u2, 'user')
response = c.post("/dashboard/vm/1/", {'wake_up': True}) with patch('dashboard.views.messages') as msg:
self.assertEqual(response.status_code, 403) response = c.post("/dashboard/vm/1/op/wake_up/")
assert msg.error.called
self.assertEqual(response.status_code, 302)
inst = Instance.objects.get(pk=1)
self.assertEqual(inst.status, 'SUSPENDED') self.assertEqual(inst.status, 'SUSPENDED')
def test_non_existing_template_get(self): def test_non_existing_template_get(self):
......
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