Commit 906fbf37 by Chif Gergő

request: Change template request test

Add request fields to tests to see its working. Assert the message and the fields content.
parent 2b2720da
...@@ -25,7 +25,7 @@ from mock import Mock, patch ...@@ -25,7 +25,7 @@ from mock import Mock, patch
from common.tests.celery_mock import MockCeleryMixin from common.tests.celery_mock import MockCeleryMixin
from vm.models import Instance, InstanceTemplate, Lease from vm.models import Instance, InstanceTemplate, Lease
from dashboard.models import Profile from dashboard.models import Profile
from request.models import Request, LeaseType, TemplateAccessType from request.models import Request, LeaseType, TemplateAccessType, RequestField
from dashboard.tests.test_views import LoginMixin from dashboard.tests.test_views import LoginMixin
from vm.operations import ResourcesOperation from vm.operations import ResourcesOperation
...@@ -104,17 +104,24 @@ class RequestTest(LoginMixin, MockCeleryMixin, TestCase): ...@@ -104,17 +104,24 @@ class RequestTest(LoginMixin, MockCeleryMixin, TestCase):
template = InstanceTemplate.objects.get(pk=1) template = InstanceTemplate.objects.get(pk=1)
self.assertFalse(template.has_level(self.u1, "user")) self.assertFalse(template.has_level(self.u1, "user"))
field = RequestField(fieldname="Tanszek", type="Char", required=True)
field.save()
field = RequestField(fieldname="Szobaszam", type="Integer",
required=False)
field.save()
req_count = Request.objects.count() req_count = Request.objects.count()
resp = c.post("/request/template/", { resp = c.post("/request/template/", {
'template': 1, 'template': 1,
'level': "user", 'level': "user",
'message': "szia", 'field1': "IIT",
'field2': 10,
}) })
self.assertEqual(resp.status_code, 302) self.assertEqual(resp.status_code, 302)
self.assertEqual(req_count + 1, Request.objects.count()) self.assertEqual(req_count + 1, Request.objects.count())
new_request = Request.objects.latest("pk") new_request = Request.objects.latest("pk")
self.assertEqual(new_request.status, "PENDING") self.assertEqual(new_request.status, "PENDING")
self.assertEqual(new_request.message, "Tanszek: IIT\nSzobaszam: 10\n")
new_request.accept(self.us) new_request.accept(self.us)
new_request = Request.objects.latest("pk") new_request = Request.objects.latest("pk")
......
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