def test_change_status(self):
     orig_date_modified = self.system.date_modified
     b = self.browser
     login(b)
     self.go_to_system_view(tab='Scheduler Settings')
     tab = b.find_element_by_id('scheduler-settings')
     BootstrapSelect(tab.find_element_by_name('status'))\
         .select_by_visible_text('Broken')
     tab.find_element_by_xpath('.//button[text()="Save Changes"]').click()
     b.find_element_by_xpath('//span[@class="label label-warning"'
             ' and text()="Out of service"]')
     with session.begin():
         session.refresh(self.system)
         self.assertEqual(self.system.status, SystemStatus.broken)
         self.assertEqual(len(self.system.status_durations), 2)
         self.assertEqual(self.system.status_durations[0].status,
                 SystemStatus.broken)
         assertions.assert_datetime_within(
                 self.system.status_durations[0].start_time,
                 tolerance=datetime.timedelta(seconds=60),
                 reference=datetime.datetime.utcnow())
         self.assert_(self.system.status_durations[0].finish_time is None)
         self.assert_(self.system.status_durations[1].finish_time is not None)
         assertions.assert_durations_not_overlapping(
                 self.system.status_durations)
         self.assert_(self.system.date_modified > orig_date_modified)
Exemple #2
0
 def test_release_system(self):
     with session.begin():
         system = data_setup.create_system(
                 owner=User.by_user_name(data_setup.ADMIN_USER),
                 status=u'Manual', shared=True)
         user = data_setup.create_user(password=u'password')
         system.reserve_manually(service=u'testdata', user=user)
     server = self.get_server()
     server.auth.login_password(user.user_name, 'password')
     server.systems.release(system.fqdn)
     with session.begin():
         session.refresh(system)
         session.refresh(system.reservations[0])
         self.assert_(system.user is None)
         self.assertEquals(system.reservations[0].user, user)
         assert_datetime_within(system.reservations[0].finish_time,
                 tolerance=datetime.timedelta(seconds=10),
                 reference=datetime.datetime.utcnow())
         assert_durations_not_overlapping(system.reservations)
         released_activity = system.activity[0]
         self.assertEqual(released_activity.action, 'Returned')
         self.assertEqual(released_activity.field_name, 'User')
         self.assertEqual(released_activity.user, user)
         self.assertEqual(released_activity.old_value, user.user_name)
         self.assertEqual(released_activity.new_value, '')
         self.assertEqual(released_activity.service, 'XMLRPC')
Exemple #3
0
 def test_reserve_via_external_service(self):
     with session.begin():
         service_group = data_setup.create_group(
             permissions=[u'proxy_auth'])
         service_user = data_setup.create_user(password=u'password')
         data_setup.add_user_to_group(service_user, service_group)
         user = data_setup.create_user(password=u'notused')
         system = data_setup.create_system(owner=User.by_user_name(
             data_setup.ADMIN_USER),
                                           status=u'Manual',
                                           shared=True)
         self.assert_(system.user is None)
     server = self.get_server()
     server.auth.login_password(service_user.user_name, 'password',
                                user.user_name)
     server.systems.reserve(system.fqdn)
     with session.begin():
         session.refresh(system)
         self.assertEqual(system.user, user)
         self.assertEqual(system.reservations[0].type, u'manual')
         self.assertEqual(system.reservations[0].user, user)
         self.assert_(system.reservations[0].finish_time is None)
         assert_durations_not_overlapping(system.reservations)
         reserved_activity = system.activity[0]
         self.assertEqual(reserved_activity.action, 'Reserved')
         self.assertEqual(reserved_activity.service, service_user.user_name)
Exemple #4
0
 def test_change_status(self):
     orig_date_modified = self.system.date_modified
     b = self.browser
     login(b)
     self.go_to_system_view(tab='Scheduler Settings')
     tab = b.find_element_by_id('scheduler-settings')
     BootstrapSelect(tab.find_element_by_name('status'))\
         .select_by_visible_text('Broken')
     tab.find_element_by_xpath('.//button[text()="Save Changes"]').click()
     b.find_element_by_xpath('//span[@class="label label-warning"'
                             ' and text()="Out of service"]')
     with session.begin():
         session.refresh(self.system)
         self.assertEqual(self.system.status, SystemStatus.broken)
         self.assertEqual(len(self.system.status_durations), 2)
         self.assertEqual(self.system.status_durations[0].status,
                          SystemStatus.broken)
         assertions.assert_datetime_within(
             self.system.status_durations[0].start_time,
             tolerance=datetime.timedelta(seconds=60),
             reference=datetime.datetime.utcnow())
         self.assert_(self.system.status_durations[0].finish_time is None)
         self.assert_(
             self.system.status_durations[1].finish_time is not None)
         assertions.assert_durations_not_overlapping(
             self.system.status_durations)
         self.assert_(self.system.date_modified > orig_date_modified)
Exemple #5
0
 def test_reserve_system(self):
     with session.begin():
         user = data_setup.create_user(password=u'password')
         system = data_setup.create_system(
                 owner=User.by_user_name(data_setup.ADMIN_USER),
                 status=u'Manual', shared=True)
         self.assert_(system.user is None)
     server = self.get_server()
     server.auth.login_password(user.user_name, 'password')
     server.systems.reserve(system.fqdn)
     with session.begin():
         session.refresh(system)
         self.assertEqual(system.user, user)
         self.assertEqual(system.reservations[0].type, u'manual')
         self.assertEqual(system.reservations[0].user, user)
         self.assert_(system.reservations[0].finish_time is None)
         assert_durations_not_overlapping(system.reservations)
         reserved_activity = system.activity[-1]
         self.assertEqual(reserved_activity.action, 'Reserved')
         self.assertEqual(reserved_activity.field_name, 'User')
         self.assertEqual(reserved_activity.user, user)
         self.assertEqual(reserved_activity.new_value, user.user_name)
         self.assertEqual(reserved_activity.service, 'XMLRPC')
 def test_change_status(self):
     orig_date_modified = self.system.date_modified
     b = self.browser
     login(b)
     self.go_to_system_edit()
     Select(b.find_element_by_name('status')).select_by_visible_text('Broken')
     b.find_element_by_link_text('Save Changes').click()
     self.assert_system_view_text('status', u'Broken')
     with session.begin():
         session.refresh(self.system)
         self.assertEqual(self.system.status, SystemStatus.broken)
         self.assertEqual(len(self.system.status_durations), 2)
         self.assertEqual(self.system.status_durations[0].status,
                 SystemStatus.broken)
         assertions.assert_datetime_within(
                 self.system.status_durations[0].start_time,
                 tolerance=datetime.timedelta(seconds=60),
                 reference=datetime.datetime.utcnow())
         self.assert_(self.system.status_durations[0].finish_time is None)
         self.assert_(self.system.status_durations[1].finish_time is not None)
         assertions.assert_durations_not_overlapping(
                 self.system.status_durations)
         self.assert_(self.system.date_modified > orig_date_modified)
Exemple #7
0
 def test_change_status(self):
     orig_date_modified = self.system.date_modified
     self.login()
     sel = self.selenium
     self.go_to_system_edit()
     sel.select("status", u"Broken")
     sel.click("link=Save Changes")
     sel.wait_for_page_to_load("30000")
     self.assert_system_view_text("status", u"Broken")
     with session.begin():
         session.refresh(self.system)
         self.assertEqual(self.system.status, SystemStatus.broken)
         self.assertEqual(len(self.system.status_durations), 2)
         self.assertEqual(self.system.status_durations[0].status, SystemStatus.broken)
         assertions.assert_datetime_within(
             self.system.status_durations[0].start_time,
             tolerance=datetime.timedelta(seconds=60),
             reference=datetime.datetime.utcnow(),
         )
         self.assert_(self.system.status_durations[0].finish_time is None)
         self.assert_(self.system.status_durations[1].finish_time is not None)
         assertions.assert_durations_not_overlapping(self.system.status_durations)
         self.assert_(self.system.date_modified > orig_date_modified)
Exemple #8
0
 def test_reserve_via_external_service(self):
     with session.begin():
         service_group = data_setup.create_group(permissions=[u'proxy_auth'])
         service_user = data_setup.create_user(password=u'password')
         service_group.add_member(service_user)
         user = data_setup.create_user(password=u'notused')
         system = data_setup.create_system(
                 owner=User.by_user_name(data_setup.ADMIN_USER),
                 status=u'Manual', shared=True)
         self.assert_(system.user is None)
     server = self.get_server()
     server.auth.login_password(service_user.user_name, 'password',
             user.user_name)
     server.systems.reserve(system.fqdn)
     with session.begin():
         session.refresh(system)
         self.assertEqual(system.user, user)
         self.assertEqual(system.reservations[0].type, u'manual')
         self.assertEqual(system.reservations[0].user, user)
         self.assert_(system.reservations[0].finish_time is None)
         assert_durations_not_overlapping(system.reservations)
         reserved_activity = system.activity[0]
         self.assertEqual(reserved_activity.action, 'Reserved')
         self.assertEqual(reserved_activity.service, service_user.user_name)