def test_find_with_attribute(dummy_room, create_room, create_room_attribute): assert Room.find_all() == [dummy_room] # one room without the attribute assert not Room.find_with_attribute(u'foo') create_room_attribute(u'foo') assert not Room.find_with_attribute(u'foo') expected = set() for room in [create_room(), create_room()]: value = u'bar-{}'.format(room.id) room.set_attribute_value(u'foo', value) expected.add((room, value)) assert set(Room.find_with_attribute(u'foo')) == expected
def getVars(self): vars = WJSBase.getVars( self ) roomsWithH323IP = [] if self._conf: vars["ConferenceId"] = self._conf.getId() # Code to get a list of H.323 Videoconference-able rooms # by querying Indico's RB database location = self._conf.getLocation() if location and location.getName(): locationName = location.getName() if Config.getInstance().getIsRoomBookingActive(): attr_name = getCERNMCUOptionValueByName('H323_IP_att_name') for room, ip in Room.find_with_attribute(attr_name): if validIP(ip): roomsWithH323IP.append(RoomWithH323(locationName, room.full_name, ip)) else: vars["ConferenceId"] = "" roomsWithH323IP.sort(key=lambda r: (r.getLocation(), r.getName())) vars["RoomsWithH323IP"] = roomsWithH323IP return vars
def _inject_long_term_attribute(self, sender, data, **kwargs): long_term_room_ids = { room.id for room, value in Room.find_with_attribute('long-term') if value.lower() in ('true', '1', 'yes') } for room in data: room['is_long_term'] = room['id'] in long_term_room_ids