diff options
Diffstat (limited to 'src/dashboard')
-rw-r--r-- | src/dashboard/testing_utils.py | 25 | ||||
-rw-r--r-- | src/dashboard/views.py | 2 |
2 files changed, 16 insertions, 11 deletions
diff --git a/src/dashboard/testing_utils.py b/src/dashboard/testing_utils.py index a96b6d0..0f52daa 100644 --- a/src/dashboard/testing_utils.py +++ b/src/dashboard/testing_utils.py @@ -103,12 +103,16 @@ def make_config_bundle(grb, owner, topology={}, host_set={}, cb = ConfigBundle.objects.create( owner=owner, name="config bundle " + str(ConfigBundle.objects.count()), - description="cb generated by make_config_bundle() method" + description="cb generated by make_config_bundle() method", + bundle=grb ) + scen = scenario or Scenario.objects.first() or make_scenario() + inst = installer or Installer.objects.first() or make_installer([scen]) + opnfv_config = OPNFVConfig.objects.create( - installer=installer, - scenario=scenario, + installer=inst, + scenario=scen, bundle=cb ) @@ -194,7 +198,8 @@ def make_generic_host(grb, host_profile, hostname): def make_user(is_superuser=False, username="testuser", password="testpassword", email="default_email@user.com"): - user = User.objects.create_user(username=username, email=email, password=password) + user = User.objects.get_or_create(username=username, email=email, password=password)[0] + user.is_superuser = is_superuser user.save() @@ -204,14 +209,14 @@ def make_user(is_superuser=False, username="testuser", def make_user_profile(user=None, email_addr="email@email.com", company="company", full_name="John Doe", booking_privledge=True, ssh_file=None): - user = user or User.objects.first() or make_user() - profile = UserProfile.objects.create( + user = user or make_user() + profile = UserProfile.objects.get_or_create( email_addr=email_addr, company=company, full_name=full_name, booking_privledge=booking_privledge, user=user - ) + )[0] profile.ssh_public_key.save("user_ssh_key", ssh_file if ssh_file else ContentFile("public key content string")) return profile @@ -238,7 +243,7 @@ def make_lab(user=None, name="Test_Lab_Instance", vlan_manager = make_vlan_manager() if not user: - user = make_user() + user = make_user(username=name + " user") lab = Lab.objects.create( lab_user=user, @@ -354,7 +359,9 @@ def make_installer(scenarios, name="test installer"): return installer -def make_os(installers, name="test OS"): +def make_os(installers=None, name="test OS"): + if not installers: + installers = [make_installer([make_scenario()])] os = Opsys.objects.create(name=name) for installer in installers: os.sup_installers.add(installer) diff --git a/src/dashboard/views.py b/src/dashboard/views.py index 9416cb4..c387251 100644 --- a/src/dashboard/views.py +++ b/src/dashboard/views.py @@ -12,12 +12,10 @@ from django.shortcuts import get_object_or_404 from django.views.generic import TemplateView from django.shortcuts import render -from django.http import HttpResponseRedirect from account.models import Lab from resource_inventory.models import Image, HostProfile -from workflow.views import create_session from workflow.workflow_manager import ManagerTracker |