diff options
author | maxbr <maxbr@mi.fu-berlin.de> | 2016-08-22 18:59:47 +0200 |
---|---|---|
committer | maxbr <maxbr@mi.fu-berlin.de> | 2016-08-22 19:04:19 +0200 |
commit | 6c993d9e3bd9a7c0fb94d7056e664648dd8d85cb (patch) | |
tree | 8ae572cb4454cd9de3aca27b88d08dadf76cbdf3 /tools/pharos-dashboard/booking/tests/test_models.py | |
parent | 7528d995257181b91c0d82dd82a2aa0f832ef63f (diff) |
Create Jira issue for new booking
JIRA: RELENG-12
The issue is assigned to the lab owner and to the POD Access Request
Component. The pgp and ssh keys are uploaded to jira as an attachement.
Signed-off-by: maxbr <maxbr@mi.fu-berlin.de>
Diffstat (limited to 'tools/pharos-dashboard/booking/tests/test_models.py')
-rw-r--r-- | tools/pharos-dashboard/booking/tests/test_models.py | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/tools/pharos-dashboard/booking/tests/test_models.py b/tools/pharos-dashboard/booking/tests/test_models.py index 00f6b266..7a572c5f 100644 --- a/tools/pharos-dashboard/booking/tests/test_models.py +++ b/tools/pharos-dashboard/booking/tests/test_models.py @@ -4,6 +4,7 @@ from django.contrib.auth.models import User, Permission from django.test import TestCase from django.utils import timezone +from account.models import UserProfile from booking.models import Booking from dashboard.models import Resource from jenkins.models import JenkinsSlave @@ -12,9 +13,12 @@ from jenkins.models import JenkinsSlave class BookingModelTestCase(TestCase): def setUp(self): self.slave = JenkinsSlave.objects.create(name='test', url='test') + self.owner = User.objects.create(username='owner') - self.res1 = Resource.objects.create(name='res1', slave=self.slave, description='x', url='x') - self.res2 = Resource.objects.create(name='res2', slave=self.slave, description='x', url='x') + self.res1 = Resource.objects.create(name='res1', slave=self.slave, description='x', + url='x',owner=self.owner) + self.res2 = Resource.objects.create(name='res2', slave=self.slave, description='x', + url='x',owner=self.owner) self.user1 = User.objects.create(username='user1') @@ -78,12 +82,14 @@ class BookingModelTestCase(TestCase): def test_authorization(self): user = User.objects.create(username='user') + user.userprofile = UserProfile.objects.create(user=user) self.assertRaises(PermissionError, Booking.objects.create, start=timezone.now(), end=timezone.now() + timedelta(days=1), resource=self.res1, user=user) - self.res1.owners.add(user) + self.res1.owner = user self.assertTrue( Booking.objects.create(start=timezone.now(), end=timezone.now() + timedelta(days=1), resource=self.res1, user=user)) + self.res1.owner = self.owner user.user_permissions.add(self.add_booking_perm) user = User.objects.get(pk=user.id) self.assertTrue( |