Commit f3ef3c2a by Dudás Ádám

Merge branch 'issue-446-v2' into 'master'

Fix crispy forms error

Close #446 

See merge request !369
parents cb2d9cff 786cff68
Pipeline #62 passed with stage
in 0 seconds
......@@ -270,33 +270,6 @@ class VmDetailTest(LoginMixin, MockCeleryMixin, TestCase):
self.assertEqual(InstanceTemplate.objects.get(id=1).raw_data,
"<devices></devices>")
def test_permitted_lease_delete_w_template_using_it(self):
c = Client()
self.login(c, 'superuser')
leases = Lease.objects.count()
response = c.post("/dashboard/lease/delete/1/")
self.assertEqual(response.status_code, 400)
self.assertEqual(leases, Lease.objects.count())
def test_permitted_lease_delete_w_template_not_using_it(self):
c = Client()
self.login(c, 'superuser')
lease = Lease.objects.create(name="yay")
leases = Lease.objects.count()
response = c.post("/dashboard/lease/delete/%d/" % lease.pk)
self.assertEqual(response.status_code, 302)
self.assertEqual(leases - 1, Lease.objects.count())
def test_unpermitted_lease_delete(self):
c = Client()
self.login(c, 'user1')
leases = Lease.objects.count()
response = c.post("/dashboard/lease/delete/1/")
# redirect to the login page
self.assertEqual(response.status_code, 403)
self.assertEqual(leases, Lease.objects.count())
def test_notification_read(self):
c = Client()
self.login(c, "user1")
......@@ -1758,3 +1731,76 @@ class SshKeyTest(LoginMixin, TestCase):
resp = c.post("/dashboard/sshkey/delete/1/")
self.assertEqual(403, resp.status_code)
class LeaseDetailTest(LoginMixin, TestCase):
fixtures = ['test-vm-fixture.json', ]
def setUp(self):
self.u1 = User.objects.create(username='user1')
self.u1.set_password('password')
self.u1.save()
self.u2 = User.objects.create(username='user2', is_staff=True)
self.u2.set_password('password')
self.u2.save()
self.us = User.objects.create(username='superuser', is_superuser=True)
self.us.set_password('password')
self.us.save()
def tearDown(self):
super(LeaseDetailTest, self).tearDown()
self.u1.delete()
self.u2.delete()
self.us.delete()
def test_anon_view(self):
c = Client()
response = c.get("/dashboard/lease/1/")
self.assertEqual(response.status_code, 302)
def test_unpermitted_view(self):
c = Client()
self.login(c, 'user1')
response = c.get("/dashboard/lease/1/")
self.assertEqual(response.status_code, 302)
def test_operator_view(self):
c = Client()
self.login(c, 'user2')
lease = Lease.objects.get()
lease.set_level(self.u2, "owner")
response = c.get("/dashboard/lease/1/")
self.assertEqual(response.status_code, 200)
def test_superuser_view(self):
c = Client()
self.login(c, 'superuser')
response = c.get("/dashboard/lease/1/")
self.assertEqual(response.status_code, 200)
def test_permitted_lease_delete_w_template_using_it(self):
c = Client()
self.login(c, 'superuser')
leases = Lease.objects.count()
response = c.post("/dashboard/lease/delete/1/")
self.assertEqual(response.status_code, 400)
self.assertEqual(leases, Lease.objects.count())
def test_permitted_lease_delete_w_template_not_using_it(self):
c = Client()
self.login(c, 'superuser')
lease = Lease.objects.create(name="yay")
leases = Lease.objects.count()
response = c.post("/dashboard/lease/delete/%d/" % lease.pk)
self.assertEqual(response.status_code, 302)
self.assertEqual(leases - 1, Lease.objects.count())
def test_unpermitted_lease_delete(self):
c = Client()
self.login(c, 'user1')
leases = Lease.objects.count()
response = c.post("/dashboard/lease/delete/1/")
# redirect to the login page
self.assertEqual(response.status_code, 403)
self.assertEqual(leases, Lease.objects.count())
amqp==1.4.6
anyjson==0.3.3
arrow==0.6.0
arrow==0.7.0
billiard==3.3.0.20
bpython==0.14.1
celery==3.1.18
Django==1.8.2
Django==1.8.12
django-appconf==1.0.1
django-autocomplete-light==2.1.1
django-braces==1.8.0
django-crispy-forms==1.4.0
django-crispy-forms==1.6.0
django-model-utils==2.2
djangosaml2==0.13.0
django-sizefield==0.7
......
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