summaryrefslogtreecommitdiffstats
path: root/dashboard/src/api/tests
diff options
context:
space:
mode:
authorParker Berberian <pberberian@iol.unh.edu>2018-11-20 11:19:55 -0500
committerParker Berberian <pberberian@iol.unh.edu>2018-11-26 14:07:15 -0500
commitf2bbdbbf7e03be031723a9680aa9deaf80e4a99c (patch)
tree54086b0ae60b65da0905e3b51c922934247b5370 /dashboard/src/api/tests
parent674812a20f6804c287e1355ec8a1adf907798a94 (diff)
Fix all flake8 errors
The flake8 command in test.sh finds no longer finds any errors. This may form a basis of a jenkins verify job as a sort of 'weak compile-time checks' The flake8 command will not complain about line length, and will not complain about django's manage.py file Change-Id: Ic47cb4fc7ada55e64485661ab6881aef475018ff Signed-off-by: Parker Berberian <pberberian@iol.unh.edu>
Diffstat (limited to 'dashboard/src/api/tests')
-rw-r--r--dashboard/src/api/tests/__init__.py2
-rw-r--r--dashboard/src/api/tests/test_serializers.py80
2 files changed, 49 insertions, 33 deletions
diff --git a/dashboard/src/api/tests/__init__.py b/dashboard/src/api/tests/__init__.py
index fe2a32d..2435a9f 100644
--- a/dashboard/src/api/tests/__init__.py
+++ b/dashboard/src/api/tests/__init__.py
@@ -5,4 +5,4 @@
# are made available under the terms of the Apache License, Version 2.0
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
-############################################################################## \ No newline at end of file
+##############################################################################
diff --git a/dashboard/src/api/tests/test_serializers.py b/dashboard/src/api/tests/test_serializers.py
index c49010c..c1fa5af 100644
--- a/dashboard/src/api/tests/test_serializers.py
+++ b/dashboard/src/api/tests/test_serializers.py
@@ -8,12 +8,29 @@
##############################################################################
from django.test import TestCase
from booking.models import Booking
-from resource_inventory.models import *
from account.models import Lab
-from api.serializers.booking_serializer import *
+from api.serializers.booking_serializer import BookingField
from datetime import timedelta
from django.utils import timezone
from django.contrib.auth.models import Permission, User
+from resource_inventory.models import (
+ Image,
+ OPNFVRole,
+ HostConfiguration,
+ HostProfile,
+ InterfaceProfile,
+ DiskProfile,
+ CpuProfile,
+ RamProfile,
+ GenericResourceBundle,
+ GenericResource,
+ GenericHost,
+ Host,
+ Vlan,
+ Interface,
+ ConfigBundle,
+ ResourceBundle
+)
class BookingSerializerTestCase(TestCase):
@@ -24,35 +41,34 @@ class BookingSerializerTestCase(TestCase):
lab_user = User.objects.create(username="asfasdfasdf")
owner = User.objects.create(username="asfasdfasdffffff")
lab = Lab.objects.create(
- lab_user=lab_user,
- name="TestLab123123",
- contact_email="mail@email.com",
- contact_phone=""
- )
- jumphost=True
+ lab_user=lab_user,
+ name="TestLab123123",
+ contact_email="mail@email.com",
+ contact_phone=""
+ )
+ jumphost = True
for host in hosts:
image = Image.objects.create(
- lab_id=12,
- from_lab=lab,
- name="this is a test image",
- owner=owner
- )
+ lab_id=12,
+ from_lab=lab,
+ name="this is a test image",
+ owner=owner
+ )
name = "jumphost"
if not jumphost:
name = "compute"
role = OPNFVRole.objects.create(
- name=name,
- description="stuff"
- )
+ name=name,
+ description="stuff"
+ )
HostConfiguration.objects.create(
- host=host,
- image=image,
- bundle=config,
- opnfvRole=role
- )
- jumphost=False
-
+ host=host,
+ image=image,
+ bundle=config,
+ opnfvRole=role
+ )
+ jumphost = False
def setUp(self):
self.serializer = BookingField()
@@ -64,30 +80,30 @@ class BookingSerializerTestCase(TestCase):
name='Test profile',
description='a test profile'
)
- interfaceProfile = InterfaceProfile.objects.create(
+ InterfaceProfile.objects.create(
speed=1000,
name='eno3',
host=hostProfile
)
- diskProfile = DiskProfile.objects.create(
+ DiskProfile.objects.create(
size=1000,
media_type="SSD",
name='/dev/sda',
host=hostProfile
)
- cpuProfile = CpuProfile.objects.create(
+ CpuProfile.objects.create(
cores=96,
architecture="x86_64",
cpus=2,
host=hostProfile
)
- ramProfile = RamProfile.objects.create(
+ RamProfile.objects.create(
amount=256,
channels=4,
host=hostProfile
)
- #create GenericResourceBundle
+ # create GenericResourceBundle
genericBundle = GenericResourceBundle.objects.create()
gres1 = GenericResource.objects.create(
@@ -119,9 +135,9 @@ class BookingSerializerTestCase(TestCase):
conf = ConfigBundle.objects.create(owner=user1, name="test conf")
self.makeHostConfigurations([gHost1, gHost2], conf)
- #actual resource bundle
+ # actual resource bundle
bundle = ResourceBundle.objects.create(
- template = genericBundle
+ template=genericBundle
)
host1 = Host.objects.create(
@@ -168,8 +184,8 @@ class BookingSerializerTestCase(TestCase):
# finally, can create booking
self.booking = Booking.objects.create(
owner=user1,
- start = timezone.now(),
- end = timezone.now() + timedelta(weeks=1),
+ start=timezone.now(),
+ end=timezone.now() + timedelta(weeks=1),
purpose='Testing',
resource=bundle,
config_bundle=conf