Index: main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_browser.py
===================================================================
--- main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_browser.py	(revision 13455)
+++ main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_browser.py	(revision 13457)
@@ -1203,5 +1203,5 @@
         # Managers can use HOS code and book a bed space with it
         self.browser.open(self.acco_path)
-        self.browser.getLink("Book accommodation").click()
+        self.browser.getControl("Book accommodation").click()
         self.assertMatches('...You are in the wrong...',
                            self.browser.contents)
@@ -1210,10 +1210,10 @@
         # are in accommodation session
         self.student['studycourse'].current_session = 2003
-        self.browser.getLink("Book accommodation").click()
+        self.browser.getControl("Book accommodation").click()
         self.assertMatches('...Your current session does not match...',
                            self.browser.contents)
         self.student['studycourse'].current_session = 2004
         # All requirements are met and ticket can be created
-        self.browser.getLink("Book accommodation").click()
+        self.browser.getControl("Book accommodation").click()
         self.assertMatches('...Activation Code:...',
                            self.browser.contents)
@@ -1227,5 +1227,5 @@
         self.assertTrue(bed1.owner == self.student_id)
         # BedTicketAddPage is now blocked
-        self.browser.getLink("Book accommodation").click()
+        self.browser.getControl("Book accommodation").click()
         self.assertMatches('...You already booked a bed space...',
             self.browser.contents)
@@ -3008,4 +3008,16 @@
 
     def test_student_accommodation(self):
+        # Create a second hostel with one bed
+        hostel = Hostel()
+        hostel.hostel_id = u'hall-2'
+        hostel.hostel_name = u'Hall 2'
+        self.app['hostels'].addHostel(hostel)
+        bed = Bed()
+        bed.bed_id = u'hall-2_A_101_A'
+        bed.bed_number = 1
+        bed.owner = NOT_OCCUPIED
+        bed.bed_type = u'regular_female_fr'
+        self.app['hostels'][hostel.hostel_id].addBed(bed)
+
         self.browser.open(self.login_path)
         self.browser.getControl(name="form.login").value = self.student_id
@@ -3032,5 +3044,5 @@
         # ... but not if booking period has expired ...
         self.app['hostels'].enddate = datetime.now(pytz.utc)
-        self.browser.getLink("Book accommodation").click()
+        self.browser.getControl("Book accommodation").click()
         self.assertMatches('...Outside booking period: ...',
                            self.browser.contents)
@@ -3038,14 +3050,25 @@
         # ... or student data are incomplete ...
         self.student['studycourse'].current_level = None
-        self.browser.getLink("Book accommodation").click()
+        self.browser.getControl("Book accommodation").click()
         self.assertMatches('...Your data are incomplete...',
             self.browser.contents)
         self.student['studycourse'].current_level = 100
         # ... or student is not the an allowed state ...
-        self.browser.getLink("Book accommodation").click()
+        self.browser.getControl("Book accommodation").click()
         self.assertMatches('...You are in the wrong...',
                            self.browser.contents)
+        # Students can still not see the disired hostel selector.
+        self.assertFalse('desired hostel' in self.browser.contents)
         IWorkflowInfo(self.student).fireTransition('admit')
-        self.browser.getLink("Book accommodation").click()
+        # Students can now see the disired hostel selector.
+        self.browser.reload()
+        self.browser.open(self.acco_path)
+        self.assertTrue('desired hostel' in self.browser.contents)
+        self.browser.getControl(name="hostel").value = ['hall-2']
+        self.browser.getControl("Save").click()
+        self.assertTrue('selection has been saved' in self.browser.contents)
+        self.assertTrue('<option selected="selected" value="hall-2">'
+            in self.browser.contents)
+        self.browser.getControl("Book accommodation").click()
         self.assertMatches('...Activation Code:...',
                            self.browser.contents)
@@ -3058,4 +3081,14 @@
         # ... or ACs owned by somebody else.
         ac.owner = u'Anybody'
+        self.browser.getControl(name="ac_series").value = sfeseries
+        self.browser.getControl(name="ac_number").value = sfenumber
+        self.browser.getControl("Create bed ticket").click()
+        # Hostel 2 has only a bed for women.
+        self.assertTrue('There is no free bed in your desired hostel'
+            in self.browser.contents)
+        self.browser.getControl(name="hostel").value = ['hall-1']
+        self.browser.getControl("Save").click()
+        self.browser.getControl("Book accommodation").click()
+        # Student can't use faked ACs ...
         self.browser.getControl(name="ac_series").value = sfeseries
         self.browser.getControl(name="ac_number").value = sfenumber
@@ -3075,5 +3108,5 @@
         self.assertTrue(bed.owner == self.student_id)
         # BedTicketAddPage is now blocked.
-        self.browser.getLink("Book accommodation").click()
+        self.browser.getControl("Book accommodation").click()
         self.assertMatches('...You already booked a bed space...',
             self.browser.contents)
