summaryrefslogtreecommitdiffstats
path: root/src/workflow/tests
diff options
context:
space:
mode:
Diffstat (limited to 'src/workflow/tests')
-rw-r--r--src/workflow/tests/test_steps.py40
-rw-r--r--src/workflow/tests/test_steps_render.py7
-rw-r--r--src/workflow/tests/test_workflows.py8
3 files changed, 38 insertions, 17 deletions
diff --git a/src/workflow/tests/test_steps.py b/src/workflow/tests/test_steps.py
index 602d3dd..380102a 100644
--- a/src/workflow/tests/test_steps.py
+++ b/src/workflow/tests/test_steps.py
@@ -6,18 +6,28 @@
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
-from django.test import TestCase, client
+
+from django.test import TestCase
from dashboard.populate_db import Populator
from workflow.tests import constants
from workflow.workflow_factory import WorkflowFactory
from workflow.models import Repository
-from workflow.resource_bundle_workflow import *
-from workflow.sw_bundle_workflow import *
-from workflow.booking_workflow import *
+from workflow.resource_bundle_workflow import Define_Hardware, Define_Nets, Resource_Meta_Info, Host_Meta_Info
+from workflow.sw_bundle_workflow import SWConf_Resource_Select, Define_Software, Config_Software
+from workflow.booking_workflow import Booking_Resource_Select, SWConfig_Select, Booking_Meta
from django.http import QueryDict, HttpRequest
from django.contrib.auth.models import User
-from django.core.management import call_command
-from resource_inventory.models import *
+from resource_inventory.models import (
+ Scenario,
+ Installer,
+ OPNFVRole,
+ Image,
+ GenericResourceBundle,
+ GenericHost,
+ HostProfile,
+ GenericResource,
+ ConfigBundle
+)
class BaseStepTestCase(TestCase):
@@ -48,7 +58,7 @@ class BookingResourceSelectTestCase(BaseStepTestCase):
grb_model = GenericResourceBundle.objects.filter(owner__username="user 1").first()
grb = [{"small_name": grb_model.name, "expanded_name": "user 1", "id": grb_model.id, "string": ""}]
grb = str(grb).replace("'", '"')
- data = {"generic_resource_bundle": grb }
+ data = {"generic_resource_bundle": grb}
response, context = self.step_test(Booking_Resource_Select, data)
self.assertTrue(True)
@@ -60,11 +70,12 @@ class BookingResourceSelectTestCase(BaseStepTestCase):
data = {}
response, context = self.step_test(SWConfig_Select, data)
+
class SoftwareConfigSelectTestCase(BaseStepTestCase):
def test_step_with_good_data(self):
config_model = ConfigBundle.objects.filter(owner__username="user 1").first()
- config = [{"expanded_name":"user 1", "small_name":config_model.name, "id":config_model.id, "string":""}]
+ config = [{"expanded_name": "user 1", "small_name": config_model.name, "id": config_model.id, "string": ""}]
config = str(config).replace("'", '"')
data = {"software_bundle": config}
response, context = self.step_test(SWConfig_Select, data)
@@ -77,6 +88,7 @@ class SoftwareConfigSelectTestCase(BaseStepTestCase):
data = {}
response, context = self.step_test(SWConfig_Select, data)
+
class BookingMetaTestCase(BaseStepTestCase):
def test_step_with_good_data(self):
@@ -84,9 +96,9 @@ class BookingMetaTestCase(BaseStepTestCase):
user2 = User.objects.get(username="user 2")
john = User.objects.get(username="johnsmith")
users = [
- {"expanded_name":"", "id":user2.id, "small_name":user2.username, "string":user2.email},
- {"expanded_name":"", "id":john.id, "small_name":john.username, "string":john.email}
- ]
+ {"expanded_name": "", "id": user2.id, "small_name": user2.username, "string": user2.email},
+ {"expanded_name": "", "id": john.id, "small_name": john.username, "string": john.email}
+ ]
users = str(users).replace("'", '"')
data['users'] = users
response, context = self.step_test(Booking_Meta, data)
@@ -104,7 +116,7 @@ class DefineHardwareTestCase(BaseStepTestCase):
def test_step_with_good_data(self):
hosts = {"host_4": 1, "host_1": 1}
- labs = {"lab_1":"true"}
+ labs = {"lab_1": "true"}
data = {"hosts": hosts, "labs": labs}
response, context = self.step_test(Define_Hardware, data)
@@ -197,7 +209,7 @@ class SWConfResourceSelectTestCase(BaseStepTestCase):
grb_model = GenericResourceBundle.objects.filter(owner__username="user 1").first()
grb = [{"small_name": grb_model.name, "expanded_name": "user 1", "id": grb_model.id, "string": ""}]
grb = str(grb).replace("'", '"')
- data = {"generic_resource_bundle": grb }
+ data = {"generic_resource_bundle": grb}
response, context = self.step_test(SWConf_Resource_Select, data)
def test_step_with_bad_data(self): # TODO
@@ -220,7 +232,6 @@ class DefineSoftwareTestCase(BaseStepTestCase):
repo.el[repo.SWCONF_SELECTED_GRB] = grb
return repo
-
def test_step_with_good_data(self):
data = {"form-INITIAL_FORMS": 3, "form-MAX_NUM_FORMS": 1000}
data["form-MIN_NUM_FORMS"] = 0
@@ -268,4 +279,3 @@ class ConfigSoftwareTestCase(BaseStepTestCase):
def test_step_with_empty_data(self):
data = {}
response, context = self.step_test(Config_Software, data)
-
diff --git a/src/workflow/tests/test_steps_render.py b/src/workflow/tests/test_steps_render.py
index 3da3b3d..f3df8f2 100644
--- a/src/workflow/tests/test_steps_render.py
+++ b/src/workflow/tests/test_steps_render.py
@@ -6,8 +6,10 @@
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
+
from django.test import TestCase, Client
+
class SuperViewTestCase(TestCase):
url = "/"
client = Client()
@@ -20,17 +22,22 @@ class SuperViewTestCase(TestCase):
class DefineHardwareViewTestCase(SuperViewTestCase):
url = "/wf/workflow/step/define_hardware"
+
class DefineNetworkViewTestCase(SuperViewTestCase):
url = "/wf/workflow/step/define_net"
+
class ResourceMetaViewTestCase(SuperViewTestCase):
url = "/wf/workflow/step/resource_meta"
+
class BookingMetaViewTestCase(SuperViewTestCase):
url = "/wf/workflow/step/booking_meta"
+
class SoftwareSelectViewTestCase(SuperViewTestCase):
url = "/wf/workflow/step/software_select"
+
class ResourceSelectViewTestCase(SuperViewTestCase):
url = "/wf/workflow/step/resource_select"
diff --git a/src/workflow/tests/test_workflows.py b/src/workflow/tests/test_workflows.py
index 71d0144..7a53521 100644
--- a/src/workflow/tests/test_workflows.py
+++ b/src/workflow/tests/test_workflows.py
@@ -6,10 +6,10 @@
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
-from django.test import TestCase, client
+
+from django.test import TestCase
from workflow.workflow_factory import WorkflowFactory
from dashboard.populate_db import Populator
-from resource_inventory.models import *
"""
@@ -25,6 +25,7 @@ To remove a workflow:
POST to /wf/workflow {"cancel": ""}
"""
+
class WorkflowTestCase(TestCase):
@classmethod
@@ -62,6 +63,7 @@ class WorkflowTestCase(TestCase):
self.assertIsNone(exception)
+
class BookingWorkflowTestCase(WorkflowTestCase):
@classmethod
@@ -73,6 +75,7 @@ class BookingWorkflowTestCase(WorkflowTestCase):
def test_steps_render(self):
super(BookingWorkflowTestCase, self).render_steps()
+
class ResourceWorkflowTestCase(WorkflowTestCase):
@classmethod
@@ -84,6 +87,7 @@ class ResourceWorkflowTestCase(WorkflowTestCase):
def test_steps_render(self):
super(ResourceWorkflowTestCase, self).render_steps()
+
class ConfigWorkflowTestCase(WorkflowTestCase):
@classmethod