summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Callaghan <dcallagh@redhat.com>2011-02-01 14:32:35 +1000
committerGerrit Code Review <gerrit@maeby.djc.id.au>2011-02-01 14:32:35 +1000
commit49c835de94f2de1168731622dd5ebeafc9e74aaf (patch)
treee9175607d5121a9cd3124c4dd9dacfab95dad677
parentd2c7b49424731a473c29c31fab666cc629241583 (diff)
parentad94807574fe90fe6e37370d3646bce355dbe6e4 (diff)
Merge "admins should be able to schedule/reserve any system" into developbeaker-distribution-install-1_11-11
-rw-r--r--Server/bkr/server/model.py15
-rw-r--r--Server/bkr/server/test/selenium/test_reserve_system.py34
2 files changed, 37 insertions, 12 deletions
diff --git a/Server/bkr/server/model.py b/Server/bkr/server/model.py
index c91d7f4..d4559ef 100644
--- a/Server/bkr/server/model.py
+++ b/Server/bkr/server/model.py
@@ -1695,15 +1695,15 @@ url --url=$tree
query = System.all(user)
if type(system_status) is list:
- whereclause_items = [System.status==k for k in system_status]
- system_status_whereclause = or_(*whereclause_items)
- elif type(system_status) is SystemStatus:
- system_status_whereclause = System.status==system_status
+ query = query.filter(or_(*[System.status==k for k in system_status]))
+ elif type(system_status) is SystemStatus:
+ query = query.filter(System.status==system_status)
else: #Possibly we are none or somthing else...
- system_status_whereclause = or_(System.status==SystemStatus.by_name(u'Automated'),System.status==SystemStatus.by_name(u'Manual'))
+ query = query.filter(or_(System.status==SystemStatus.by_name(u'Automated'),
+ System.status==SystemStatus.by_name(u'Manual')))
- query = query.filter(and_(system_status_whereclause,
- or_(and_(System.owner==user,
+ if not user.is_admin():
+ query = query.filter(or_(and_(System.owner==user,
System.loaned==None),
System.loaned==user,
and_(System.shared==True,
@@ -1716,7 +1716,6 @@ url --url=$tree
)
)
)
- )
return query
diff --git a/Server/bkr/server/test/selenium/test_reserve_system.py b/Server/bkr/server/test/selenium/test_reserve_system.py
index fc76586..ea14ac4 100644
--- a/Server/bkr/server/test/selenium/test_reserve_system.py
+++ b/Server/bkr/server/test/selenium/test_reserve_system.py
@@ -4,6 +4,15 @@ from bkr.server.test import data_setup
import unittest, time, re, os
from turbogears.database import session
+def click_reserve_now(sel, system):
+ """
+ On the /reserve_system page, click the Reserve Now link corresponding
+ to the given system.
+ """
+ sel.click('//table[@id="widget"]//td[a/text()="Reserve Now" '
+ 'and preceding-sibling::td[7]/a/text() = "%s"]/a'
+ % system.fqdn)
+
class ReserveSystem(bkr.server.test.selenium.SeleniumTestCase):
def setUp(self):
self.verificationErrors = []
@@ -28,10 +37,7 @@ class ReserveSystem(bkr.server.test.selenium.SeleniumTestCase):
sel.click("link=Pick System")
sel.wait_for_page_to_load("3000")
self.failUnless(sel.is_text_present("%s" % self.system.fqdn))
- # click Reserve Now link in the same row as the system we created in setUp
- sel.click('//table[@id="widget"]//td[a/text()="Reserve Now" '
- 'and preceding-sibling::td[7]/a/text() = "%s"]/a'
- % self.system.fqdn)
+ click_reserve_now(sel, self.system)
sel.wait_for_page_to_load("30000")
sel.type("form_whiteboard", "testing")
sel.type("form_whiteboard", "test_reserve_system_distro")
@@ -40,6 +46,26 @@ class ReserveSystem(bkr.server.test.selenium.SeleniumTestCase):
try: self.failUnless(sel.is_text_present("Success"))
except AssertionError, e: self.verificationErrors.append(str(e))
+ # https://bugzilla.redhat.com/show_bug.cgi?id=672134
+ def test_admin_can_reserve_any_system(self):
+ group_system = data_setup.create_system(shared=True)
+ group_system.lab_controller = self.lc
+ group_system.groups.append(data_setup.create_group())
+ session.flush()
+ self.login(data_setup.ADMIN_USER, data_setup.ADMIN_PASSWORD)
+ sel = self.selenium
+ sel.open('distros/')
+ sel.type('simplesearch', self.distro.name)
+ sel.click('search')
+ sel.wait_for_page_to_load('30000')
+ sel.click('link=Pick System')
+ sel.wait_for_page_to_load('30000')
+ self.failUnless(sel.is_text_present(group_system.fqdn))
+ click_reserve_now(sel, group_system)
+ sel.wait_for_page_to_load('30000')
+ sel.click('//input[@value="Queue Job"]')
+ sel.wait_for_page_to_load('30000')
+ self.failUnless(sel.is_text_present('Success'))
def tearDown(self):
self.selenium.stop()