| 1 | # -*- coding: utf-8 -*- |
|---|
| 2 | ## |
|---|
| 3 | ## |
|---|
| 4 | ## This file is part of CDS Indico. |
|---|
| 5 | ## Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007 CERN. |
|---|
| 6 | ## |
|---|
| 7 | ## CDS Indico is free software; you can redistribute it and/or |
|---|
| 8 | ## modify it under the terms of the GNU General Public License as |
|---|
| 9 | ## published by the Free Software Foundation; either version 2 of the |
|---|
| 10 | ## License, or (at your option) any later version. |
|---|
| 11 | ## |
|---|
| 12 | ## CDS Indico is distributed in the hope that it will be useful, but |
|---|
| 13 | ## WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 14 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|---|
| 15 | ## General Public License for more details. |
|---|
| 16 | ## |
|---|
| 17 | ## You should have received a copy of the GNU General Public License |
|---|
| 18 | ## along with CDS Indico; if not, write to the Free Software Foundation, Inc., |
|---|
| 19 | ## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. |
|---|
| 20 | |
|---|
| 21 | from seleniumTestCase import LoggedInSeleniumTestCase, setUpModule |
|---|
| 22 | import unittest, time, re, datetime |
|---|
| 23 | |
|---|
| 24 | from indico.tests.python.unit.plugins_tests.RoomBooking_tests.roomblocking_test import RoomBooking_Feature |
|---|
| 25 | from indico.tests.python.unit.plugins import Plugins_Feature |
|---|
| 26 | |
|---|
| 27 | class RoomBookingTests(LoggedInSeleniumTestCase): |
|---|
| 28 | _requires = [RoomBooking_Feature, Plugins_Feature] |
|---|
| 29 | |
|---|
| 30 | def setUp(self): |
|---|
| 31 | super(RoomBookingTests, self).setUp() |
|---|
| 32 | |
|---|
| 33 | def test_admin(self): |
|---|
| 34 | self.go("/roomBooking.py/admin") |
|---|
| 35 | self.type(name="newLocationName", text="Test 1") |
|---|
| 36 | self.click(xpath="//input[@value='Add']") |
|---|
| 37 | self.click(ltext="Test 1") |
|---|
| 38 | self.click(xpath="//input[@value='New Room']") |
|---|
| 39 | self.type(name="name", text="Room 1") |
|---|
| 40 | self.type(name="site", text="1") |
|---|
| 41 | self.type(name="building", text="1") |
|---|
| 42 | self.type(name="floor", text="1") |
|---|
| 43 | self.type(name="roomNr", text="1") |
|---|
| 44 | self.click(css="input[type=button]") |
|---|
| 45 | self.type(id="userSearchFocusField", text="fake") |
|---|
| 46 | self.click(css="div.searchUsersButtonDiv > input[type=button]") |
|---|
| 47 | self.click(id="_GID1_existingAv0") |
|---|
| 48 | self.click(css="div.ui-dialog-buttonset > span > button[type=button]") |
|---|
| 49 | self.click(css="input.btn") |
|---|
| 50 | |
|---|
| 51 | def test_assistance(self): |
|---|
| 52 | self.go("/adminPlugins.py?pluginType=RoomBooking") |
|---|
| 53 | self.type(name="RoomBooking.assistanceNotificationEmails", text="assistance@test.pl") |
|---|
| 54 | self.click(xpath="//input[@value='Save settings']") |
|---|
| 55 | self.go("/roomBooking.py/admin") |
|---|
| 56 | self.type(name="newLocationName", text="TestUniverseAssistence1") |
|---|
| 57 | self.click(xpath="//input[@value='Add']") |
|---|
| 58 | self.click(ltext="TestUniverseAssistence1") |
|---|
| 59 | self.click(xpath="//input[@value='New Room']") |
|---|
| 60 | self.type(name="name", text="Room 1") |
|---|
| 61 | self.type(name="site", text="1") |
|---|
| 62 | self.type(name="building", text="1") |
|---|
| 63 | self.type(name="floor", text="1") |
|---|
| 64 | self.type(name="roomNr", text="1") |
|---|
| 65 | self.click(name="resvNotificationAssistance") |
|---|
| 66 | self.click(css="input[type=button]") |
|---|
| 67 | self.type(id="userSearchFocusField", text="fake") |
|---|
| 68 | self.click(css="div.searchUsersButtonDiv > input[type=button]") |
|---|
| 69 | self.click(id="_GID1_existingAv0") |
|---|
| 70 | self.click(css="div.ui-dialog-buttonset > span > button[type=button]") |
|---|
| 71 | self.click(css="input.btn") |
|---|
| 72 | self.go("/roomBooking.py/search4Rooms?forNewBooking=True") |
|---|
| 73 | self.select(name="roomName", label="TestUniverseAssistence1: 1-1-1 - Room 1") |
|---|
| 74 | self.click(css="span#bookButtonWrapper > input[type=button]") |
|---|
| 75 | self.type(name="reason", text="Test reason") |
|---|
| 76 | self.click(name="needsAssistance") |
|---|
| 77 | self.click(id="saveBooking") |
|---|
| 78 | self.click(xpath="//input[@value='Modify']") |
|---|
| 79 | self.click(name="needsAssistance") |
|---|
| 80 | self.click(id="saveBooking") |
|---|
| 81 | |
|---|
| 82 | |
|---|
| 83 | def test_create_accept_booking(self): |
|---|
| 84 | # DB setup |
|---|
| 85 | with self._context('database'): |
|---|
| 86 | self._rooms[1].resvsNeedConfirmation = True |
|---|
| 87 | # end |
|---|
| 88 | |
|---|
| 89 | self.go("/index.py") |
|---|
| 90 | self.click(css="li#userSettings a") |
|---|
| 91 | self.click(ltext="Logout") |
|---|
| 92 | self.click(ltext="Login") |
|---|
| 93 | self.type(name="login", text="fake-1") |
|---|
| 94 | self.type(name="password", text="fake-1") |
|---|
| 95 | self.click(id="loginButton") |
|---|
| 96 | self.click(ltext="Room booking") |
|---|
| 97 | self.click(name="roomLocation") |
|---|
| 98 | self.select(name="roomLocation", label="Universe") |
|---|
| 99 | self.click(css="td > input.btn") |
|---|
| 100 | self.click(ltext="PRE-book") |
|---|
| 101 | self.type(name="reason", text="Lecture") |
|---|
| 102 | self.click(id="saveBooking") |
|---|
| 103 | self.click(ltext="Logout") |
|---|
| 104 | self.click(css="strong") |
|---|
| 105 | self.type(name="login", text="dummyuser") |
|---|
| 106 | self.type(name="password", text="dummyuser") |
|---|
| 107 | self.click(id="loginButton") |
|---|
| 108 | self.click(ltext="Server admin") |
|---|
| 109 | self.click(ltext="Rooms") |
|---|
| 110 | self.click(ltext="Configuration") |
|---|
| 111 | self.click(ltext="Universe") |
|---|
| 112 | self.select(name="roomID", label="1-b-c - DummyRoom2") |
|---|
| 113 | self.click(css="input.btn") |
|---|
| 114 | self.click(css="span.fakeLink") |
|---|
| 115 | self.click(xpath="//div[@id='roomBookingCal']/div[2]/div[2]/div/div[2]/div/div/p[2]") |
|---|
| 116 | self.click(xpath="//input[@value='Accept']") |
|---|
| 117 | alert = self.get_alert() |
|---|
| 118 | self.assertEqual("Are you sure you want to ACCEPT this booking?", alert.text) |
|---|
| 119 | alert.accept() |
|---|