1 ##############################################################################
2 # Copyright (c) 2018 Parker Berberian, Sawyer Bergeron, and others.
4 # All rights reserved. This program and the accompanying materials
5 # are made available under the terms of the Apache License, Version 2.0
6 # which accompanies this distribution, and is available at
7 # http://www.apache.org/licenses/LICENSE-2.0
8 ##############################################################################
9 from django.test import TestCase, client
10 from workflow.workflow_factory import WorkflowFactory
11 from dashboard.populate_db import Populator
12 from resource_inventory.models import *
17 POST to /wf/workflow {"add": <wf_type_int>
25 POST to /wf/workflow {"cancel": ""}
28 class WorkflowTestCase(TestCase):
31 def setUpTestData(cls):
32 Populator().populate()
36 self.create_workflow(self.wf_type)
38 def create_workflow(self, wf_type):
41 # creates workflow on backend
42 self.client.post("/", {"create": int(wf_type)}) # TODO: verify content type, etc
44 def clear_workflow(self):
45 session = self.client.session
46 for k in session.keys():
50 def render_steps(self):
52 retrieves each step individually at /wf/workflow/step=<index>
54 for i in range(self.step_count):
55 # renders the step itself, not in an iframe
58 response = self.client.get("/wf/workflow/", {"step": str(i)})
59 self.assertLess(response.status_code, 300)
60 except Exception as e:
63 self.assertIsNone(exception)
65 class BookingWorkflowTestCase(WorkflowTestCase):
69 super(BookingWorkflowTestCase, cls).setUpClass()
70 cls.step_count = len(WorkflowFactory.booking_steps)
73 def test_steps_render(self):
74 super(BookingWorkflowTestCase, self).render_steps()
76 class ResourceWorkflowTestCase(WorkflowTestCase):
80 super(ResourceWorkflowTestCase, cls).setUpClass()
81 cls.step_count = len(WorkflowFactory.resource_steps)
84 def test_steps_render(self):
85 super(ResourceWorkflowTestCase, self).render_steps()
87 class ConfigWorkflowTestCase(WorkflowTestCase):
91 super(ConfigWorkflowTestCase, cls).setUpClass()
92 cls.step_count = len(WorkflowFactory.config_steps)
95 def test_steps_render(self):
96 super(ConfigWorkflowTestCase, self).render_steps()