Commit b36dc101 by Bach Dániel

dashboard: update change_password tests

parent f2ad812f
......@@ -7,6 +7,7 @@ from vm.models import Instance, InstanceTemplate, Lease, Node
from ..models import Profile
from storage.models import Disk
from firewall.models import Vlan
from mock import Mock
class LoginMixin(object):
......@@ -17,9 +18,10 @@ class LoginMixin(object):
class VmDetailTest(LoginMixin, TestCase):
fixtures = ['test-vm-fixture.json']
fixtures = ['test-vm-fixture.json', 'node.json']
def setUp(self):
Instance.get_remote_queue_name = Mock(return_value='test')
self.u1 = User.objects.create(username='user1')
......@@ -111,6 +113,19 @@ class VmDetailTest(LoginMixin, TestCase):
response ='/dashboard/vm/mass-delete/', {'vms': [1]})
self.assertEqual(response.status_code, 302)
def test_permitted_password_change(self):
c = Client()
self.login(c, "user2")
inst = Instance.objects.get(pk=1)
inst.set_level(self.u2, 'owner')
inst.node = Node.objects.all()[0]
password =
response ="/dashboard/vm/1/", {'change_password': True})
self.assertEqual(response.status_code, 302)
self.assertNotEqual(password, Instance.objects.get(pk=1).pw)
def test_unpermitted_password_change(self):
c = Client()
self.login(c, "user2")
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