summaryrefslogtreecommitdiffstats
path: root/src/booking/tests/test_models.py
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
commitb7c4d286ffa618be0e95b15f3883e2f6920a3fb1 (patch)
tree930e9b9282b8f50e671844b2a1e7f39dc5d6035d /src/booking/tests/test_models.py
parent6a90796de1df8d74c79415c39c867ffe6cd80fd0 (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 'src/booking/tests/test_models.py')
-rw-r--r--src/booking/tests/test_models.py63
1 files changed, 38 insertions, 25 deletions
diff --git a/src/booking/tests/test_models.py b/src/booking/tests/test_models.py
index a83f817..c7fb25d 100644
--- a/src/booking/tests/test_models.py
+++ b/src/booking/tests/test_models.py
@@ -11,25 +11,33 @@
from datetime import timedelta
-from django.contrib.auth.models import Permission
+from django.contrib.auth.models import Permission, User
from django.test import TestCase
from django.utils import timezone
-from booking.models import *
+# from booking.models import *
+from booking.models import Booking
from resource_inventory.models import ResourceBundle, GenericResourceBundle, ConfigBundle
+
class BookingModelTestCase(TestCase):
+
count = 0
+
def setUp(self):
self.owner = User.objects.create(username='owner')
self.res1 = ResourceBundle.objects.create(
- template=GenericResourceBundle.objects.create(name="gbundle" + str(self.count))
- )
+ template=GenericResourceBundle.objects.create(
+ name="gbundle" + str(self.count)
+ )
+ )
self.count += 1
self.res2 = ResourceBundle.objects.create(
- template=GenericResourceBundle.objects.create(name="gbundle2" + str(self.count))
- )
+ template=GenericResourceBundle.objects.create(
+ name="gbundle2" + str(self.count)
+ )
+ )
self.count += 1
self.user1 = User.objects.create(username='user1')
@@ -37,12 +45,15 @@ class BookingModelTestCase(TestCase):
self.user1.user_permissions.add(self.add_booking_perm)
self.user1 = User.objects.get(pk=self.user1.id)
- self.config_bundle = ConfigBundle.objects.create(owner=self.user1, name="test config")
+ self.config_bundle = ConfigBundle.objects.create(
+ owner=self.user1,
+ name="test config"
+ )
def test_start_end(self):
"""
- if the start of a booking is greater or equal then the end, saving should raise a
- ValueException
+ if the start of a booking is greater or equal then the end,
+ saving should raise a ValueException
"""
start = timezone.now()
end = start - timedelta(weeks=1)
@@ -54,7 +65,7 @@ class BookingModelTestCase(TestCase):
resource=self.res1,
owner=self.user1,
config_bundle=self.config_bundle
- )
+ )
end = start
self.assertRaises(
ValueError,
@@ -64,11 +75,12 @@ class BookingModelTestCase(TestCase):
resource=self.res1,
owner=self.user1,
config_bundle=self.config_bundle
- )
+ )
def test_conflicts(self):
"""
- saving an overlapping booking on the same resource should raise a ValueException
+ saving an overlapping booking on the same resource
+ should raise a ValueException
saving for different resources should succeed
"""
start = timezone.now()
@@ -80,8 +92,8 @@ class BookingModelTestCase(TestCase):
owner=self.user1,
resource=self.res1,
config_bundle=self.config_bundle
- )
)
+ )
self.assertRaises(
ValueError,
@@ -91,7 +103,8 @@ class BookingModelTestCase(TestCase):
resource=self.res1,
owner=self.user1,
config_bundle=self.config_bundle
- )
+ )
+
self.assertRaises(
ValueError,
Booking.objects.create,
@@ -100,7 +113,7 @@ class BookingModelTestCase(TestCase):
resource=self.res1,
owner=self.user1,
config_bundle=self.config_bundle
- )
+ )
self.assertRaises(
ValueError,
@@ -110,7 +123,7 @@ class BookingModelTestCase(TestCase):
resource=self.res1,
owner=self.user1,
config_bundle=self.config_bundle
- )
+ )
self.assertRaises(
ValueError,
@@ -120,7 +133,7 @@ class BookingModelTestCase(TestCase):
resource=self.res1,
owner=self.user1,
config_bundle=self.config_bundle
- )
+ )
self.assertRaises(
ValueError,
@@ -130,7 +143,7 @@ class BookingModelTestCase(TestCase):
resource=self.res1,
owner=self.user1,
config_bundle=self.config_bundle
- )
+ )
self.assertRaises(
ValueError,
@@ -140,7 +153,7 @@ class BookingModelTestCase(TestCase):
resource=self.res1,
owner=self.user1,
config_bundle=self.config_bundle
- )
+ )
self.assertTrue(
Booking.objects.create(
@@ -149,8 +162,9 @@ class BookingModelTestCase(TestCase):
owner=self.user1,
resource=self.res1,
config_bundle=self.config_bundle
- )
)
+ )
+
self.assertTrue(
Booking.objects.create(
start=end,
@@ -158,8 +172,8 @@ class BookingModelTestCase(TestCase):
owner=self.user1,
resource=self.res1,
config_bundle=self.config_bundle
- )
)
+ )
self.assertTrue(
Booking.objects.create(
@@ -168,8 +182,8 @@ class BookingModelTestCase(TestCase):
owner=self.user1,
resource=self.res1,
config_bundle=self.config_bundle
- )
)
+ )
self.assertTrue(
Booking.objects.create(
@@ -178,8 +192,8 @@ class BookingModelTestCase(TestCase):
owner=self.user1,
resource=self.res1,
config_bundle=self.config_bundle
- )
)
+ )
self.assertTrue(
Booking.objects.create(
@@ -188,8 +202,8 @@ class BookingModelTestCase(TestCase):
owner=self.user1,
resource=self.res2,
config_bundle=self.config_bundle
- )
)
+ )
def test_extensions(self):
"""
@@ -223,4 +237,3 @@ class BookingModelTestCase(TestCase):
self.assertTrue(booking.save())
except Exception:
self.fail("save() threw an exception")
-