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 (
21 GenericResourceBundle,
33 return Scenario.objects.create(name="testScenario")
37 inst = Installer.objects.create(name="testInstaller")
38 inst.sup_scenarios = [ConfigUtil.makeScenario()]
43 os = Opsys.objects.create(name="test Operating System")
44 os.sup_installers = [ConfigUtil.makeInstaller()]
48 def makeConfigBundle():
49 user = User.objects.create(username="test_user" + str(ConfigUtil.count))
51 return ConfigBundle.objects.create(owner=user)
54 def makeOPNFVConfig():
55 installer = ConfigUtil.makeInstaller()
56 scenario = ConfigUtil.makeScenario()
57 bundle = ConfigUtil.makeConfigBundle()
58 return OPNFVConfig.objects.create(
66 return OPNFVRole.objects.create(
68 description="This is a test role"
73 owner = User.objects.create(username="another test user")
74 lab_user = User.objects.create(username="labUserForTests")
75 lab = Lab.objects.create(
77 name="this is lab for testing",
78 contact_email="email@mail.com",
79 contact_phone="123-4567"
82 return Image.objects.create(
83 cobbler_id="profile1",
85 name="an image for testing",
90 def makeGenericHost():
91 profile = HostProfile.objects.create(
93 name="test lab for config bundle",
94 description="this is a test profile"
96 user = User.objects.create(username="test sample user 12")
97 bundle = GenericResourceBundle.objects.create(
98 name="Generic bundle for config tests",
104 resource = GenericResource.objects.create(
106 name="a test generic resource"
109 return GenericHost.objects.create(
115 def makeHostConfiguration():
116 host = ConfigUtil.makeGenericHost()
117 image = ConfigUtil.makeImage()
118 bundle = ConfigUtil.makeConfigBundle()
119 opnfvRole = ConfigUtil.makeOPNFVRole()
120 return HostConfiguration.objects.create(
128 class ScenarioTestCase(TestCase):
131 self.assertTrue(ConfigUtil.makeScenario())
134 class InstallerTestCase(TestCase):
137 self.assertTrue(ConfigUtil.makeInstaller())
140 class OperatingSystemTestCase(TestCase):
143 self.assertTrue(ConfigUtil.makeOpsys())
146 class ConfigBundleTestCase(TestCase):
149 self.assertTrue(ConfigUtil.makeConfigBundle())
152 class OPNFVConfigTestCase(TestCase):
155 self.assertTrue(ConfigUtil.makeOPNFVConfig())
158 class OPNFVRoleTestCase(TestCase):
161 self.assertTrue(ConfigUtil.makeOPNFVRole())
164 class HostConfigurationTestCase(TestCase):
167 self.assertTrue(ConfigUtil.makeHostConfiguration())
170 class ImageTestCase(TestCase):
173 self.assertTrue(ConfigUtil.makeImage())