def test_addOfficeHour(self): b = F.addBuilding("Office Hour Test", "ET") l = F.addLocation(b, "2nd", "201") s = F.addSchedule("1/1/2000", "1pm", ["Monday", "Tuesday"], "2pm", "1/1/2010") oh = F.addOfficeHour(s, l) self.assert_(oh.type == "Office Hours") self.assert_(oh.location.building.name == "Office Hour Test" and oh.location.building.abbreviation == "ET") self.assert_(oh.location.floor == "2nd" and oh.location.room == "201") self.assert_(oh.schedule.start_date == "1/1/2000" and oh.schedule.end_date == "1/1/2010") self.assert_(oh.schedule.start_time == "1pm" and oh.schedule.end_time == "2pm") self.assert_("Monday" in oh.schedule.days and "Tuesday" in oh.schedule.days) db.put(oh) key = oh.key() oh = db.get(key) self.assert_(oh.type == "Office Hours") self.assert_(oh.location.building.name == "Office Hour Test" and oh.location.building.abbreviation == "ET") self.assert_(oh.location.floor == "2nd" and oh.location.room == "201") self.assert_(oh.schedule.start_date == "1/1/2000" and oh.schedule.end_date == "1/1/2010") self.assert_(oh.schedule.start_time == "1pm" and oh.schedule.end_time == "2pm") self.assert_("Monday" in oh.schedule.days and "Tuesday" in oh.schedule.days)
def test_addLocation(self): b = F.addBuilding("Location Test", "LT") l = F.addLocation(b, "2nd", "201") self.assert_(l.building.name == "Location Test" and l.building.abbreviation == "LT") self.assert_(l.floor == "2nd" and l.room == "201") key = l.key() l = db.get(key) self.assert_(l.building.name == "Location Test" and l.building.abbreviation == "LT") self.assert_(l.floor == "2nd" and l.room == "201")
def put_location(location): """ pulls xml 'floor' and 'room' from xml tag 'location', makes Building DB object via function, associates it all together in a DB Location object Keyword arguments: location -- xml tag 'location' return reference to DB Location object """ building = put_building(location.find('building')) floor = get_text(location.find('floor')) room = get_text(location.find('room')) return Faculty3.addLocation(building, floor, room)
def test_addRetrieveOffice(self): b = F.addBuilding("Office Test", "ET") l = F.addLocation(b, "2nd", "201") o = F.addOffice(l) self.assert_(o.location.building.name == "Office Test" and o.location.building.abbreviation == "ET") self.assert_(o.location.floor == "2nd" and o.location.room == "201") db.put(o) key = o.key() o = db.get(key) self.assert_(o.location.building.name == "Office Test" and o.location.building.abbreviation == "ET") self.assert_(o.location.floor == "2nd" and o.location.room == "201")
def test_addRetrieveEvent(self): b = F.addBuilding("Event Test", "ET") l = F.addLocation(b, "2nd", "201") s = F.addSchedule("1/1/2000", "1pm", ["Monday", "Tuesday"], "2pm", "1/1/2010") e = F.addEvent("Meeting", s, l) self.assert_(e.type == "Meeting") self.assert_(e.location.building.name == "Event Test" and e.location.building.abbreviation == "ET") self.assert_(e.location.floor == "2nd" and e.location.room == "201") db.put(e) key = e.key() e = db.get(key) self.assert_(e.type == "Meeting") self.assert_(e.location.building.name == "Event Test" and e.location.building.abbreviation == "ET") self.assert_(e.location.floor == "2nd" and e.location.room == "201")
def put_offices(offices): """ makes DB Office objects, associating them with their person Keyword arguments: person_handle -- person that owns these offices offices -- list of offices to associate with person no return """ l = [] for office in offices: building = put_building(office.find('building')) floor = get_text(office.find('floor')) room = get_text(office.find('room')) location = Faculty3.addLocation(building, floor, room) l.append(Faculty3.addOffice(location)) return l
def test_addRetrieveCourse(self): name1 = F.addName("Staff", "Member") name2 = F.addName("WHAT", "MORE") sched = F.addSchedule("1/15/2010", "11am", ["Monday", "Wednesday", "Friday"], "12pm", "5/7/2010") b = F.addBuilding("Course Test", "ET") l = F.addLocation(b, "2nd", "201") s = F.addSchedule("1/1/2000", "1pm", ["Monday", "Tuesday"], "2pm", "1/1/2010") oh = F.addOfficeHour(s, l) db.put(oh) event = F.addEvent("Meeting", sched, l) db.put(event) sm1 = F.addStaffMember(name1, oh) sm2 = F.addStaffMember(name2, oh) staff = [sm1, sm2] cn = F.addCourseNumber("CS", "373W") db.put(cn) c = F.addCourse("12345", "SWE", "Really annoying final projects", cn, "Spring", "2010", staff, event) self.assert_(c.unique_id == "12345" and c.name == "SWE" and c.description == "Really annoying final projects") self.assert_(c.semester == "Spring" and c.year == "2010") self.assert_(c.schedule.schedule.start_date == "1/15/2010" and c.schedule.schedule.end_date == "5/7/2010") self.assert_(c.schedule.schedule.start_time == "11am" and c.schedule.schedule.end_time == "12pm") self.assert_(c.course_number.department == "CS" and c.course_number.number == "373W") db.put(c) key = c.key() c = db.get(key) self.assert_(c.unique_id == "12345" and c.name == "SWE" and c.description == "Really annoying final projects") self.assert_(c.semester == "Spring" and c.year == "2010") self.assert_(c.schedule.schedule.start_date == "1/15/2010" and c.schedule.schedule.end_date == "5/7/2010") self.assert_(c.schedule.schedule.start_time == "11am" and c.schedule.schedule.end_time == "12pm") self.assert_(c.course_number.department == "CS" and c.course_number.number == "373W")
def test_addStaffMembers(self): name = F.addName("Staff", "Member") b = F.addBuilding("Staff Test", "ET") l = F.addLocation(b, "2nd", "201") s = F.addSchedule("1/1/2000", "1pm", ["Monday", "Tuesday"], "2pm", "1/1/2010") oh = F.addOfficeHour(s, l) db.put(oh) sm = F.addStaffMember(name, oh) self.assert_(sm.name.first == "Staff" and sm.name.last == "Member") self.assert_(sm.office_hours.type == "Office Hours") self.assert_( sm.office_hours.location.building.name == "Staff Test" and sm.office_hours.location.building.abbreviation == "ET" ) self.assert_(sm.office_hours.location.floor == "2nd" and sm.office_hours.location.room == "201") self.assert_( sm.office_hours.schedule.start_date == "1/1/2000" and sm.office_hours.schedule.end_date == "1/1/2010" ) self.assert_(sm.office_hours.schedule.start_time == "1pm" and sm.office_hours.schedule.end_time == "2pm") self.assert_("Monday" in sm.office_hours.schedule.days and "Tuesday" in sm.office_hours.schedule.days) key = sm.key() sm = db.get(key) self.assert_(sm.name.first == "Staff" and sm.name.last == "Member") self.assert_(sm.office_hours.type == "Office Hours") self.assert_( sm.office_hours.location.building.name == "Staff Test" and sm.office_hours.location.building.abbreviation == "ET" ) self.assert_(sm.office_hours.location.floor == "2nd" and sm.office_hours.location.room == "201") self.assert_( sm.office_hours.schedule.start_date == "1/1/2000" and sm.office_hours.schedule.end_date == "1/1/2010" ) self.assert_(sm.office_hours.schedule.start_time == "1pm" and sm.office_hours.schedule.end_time == "2pm") self.assert_("Monday" in sm.office_hours.schedule.days and "Tuesday" in sm.office_hours.schedule.days)