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
10 from django.contrib.auth.models import User
11 from account.models import Lab
12 from resource_inventory.models import *
20 return Scenario.objects.create(name="testScenario")
24 inst = Installer.objects.create(
25 name = "testInstaller"
27 inst.sup_scenarios = [ConfigUtil.makeScenario()]
32 os = Opsys.objects.create(
33 name = "test Operating System"
35 os.sup_installers = [ConfigUtil.makeInstaller()]
39 def makeConfigBundle():
40 user = User.objects.create(username="test_user" + str(ConfigUtil.count))
42 return ConfigBundle.objects.create(
47 def makeOPNFVConfig():
48 installer = ConfigUtil.makeInstaller()
49 scenario = ConfigUtil.makeScenario()
50 bundle = ConfigUtil.makeConfigBundle()
51 return OPNFVConfig.objects.create(
59 return OPNFVRole.objects.create(
61 description="This is a test role"
66 owner = User.objects.create(username="another test user")
67 lab_user = User.objects.create(username="labUserForTests")
68 lab = Lab.objects.create(
70 name="this is lab for testing",
71 contact_email="email@mail.com",
72 contact_phone="123-4567"
75 return Image.objects.create(
78 name="an image for testing",
84 def makeGenericHost():
85 profile = HostProfile.objects.create(
87 name="test lab for config bundle",
88 description="this is a test profile"
90 user = User.objects.create(username="test sample user 12")
91 bundle = GenericResourceBundle.objects.create(
92 name="Generic bundle for config tests",
98 resource = GenericResource.objects.create(
100 name="a test generic resource"
103 return GenericHost.objects.create(
109 def makeHostConfiguration():
110 host = ConfigUtil.makeGenericHost()
111 image = ConfigUtil.makeImage()
112 bundle = ConfigUtil.makeConfigBundle()
113 opnfvRole = ConfigUtil.makeOPNFVRole()
114 return HostConfiguration.objects.create(
122 class ScenarioTestCase(TestCase):
125 self.assertTrue(ConfigUtil.makeScenario())
127 class InstallerTestCase(TestCase):
130 self.assertTrue(ConfigUtil.makeInstaller())
132 class OperatingSystemTestCase(TestCase):
135 self.assertTrue(ConfigUtil.makeOpsys())
137 class ConfigBundleTestCase(TestCase):
140 self.assertTrue(ConfigUtil.makeConfigBundle())
142 class OPNFVConfigTestCase(TestCase):
145 self.assertTrue(ConfigUtil.makeOPNFVConfig())
147 class OPNFVRoleTestCase(TestCase):
150 self.assertTrue(ConfigUtil.makeOPNFVRole())
153 class HostConfigurationTestCase(TestCase):
156 self.assertTrue(ConfigUtil.makeHostConfiguration())
159 class ImageTestCase(TestCase):
162 self.assertTrue(ConfigUtil.makeImage())