コード例 #1
0
ファイル: TestFaculty.py プロジェクト: tfausak/class
    def test_addRetrieveStudent(self):

        name = F.addName("Some", "Student")
        name1 = F.addName("Some", "Faculty")
        faculty = F.addFaculty(name, ["*****@*****.**"], "Lecturer", "sfac")

        student = F.addStudent(name, ["*****@*****.**", "*****@*****.**"], "PhD Student", "stud", [faculty])

        self.assert_(student.username == "stud")
        self.assert_("*****@*****.**" in student.emails and "*****@*****.**" in student.emails)
        self.assert_(student.name.first == "Some")
        self.assert_(student.name.last == "Student")
        self.assert_(student.name.suffix is None)
        self.assert_(student.name.middle is None)
        self.assert_(faculty.key() in student.advisors)

        key = student.key()

        student = db.get(key)

        self.assert_(student.username == "stud")
        self.assert_("*****@*****.**" in student.emails and "*****@*****.**" in student.emails)
        self.assert_(student.name.first == "Some")
        self.assert_(student.name.last == "Student")
        self.assert_(student.name.suffix is None)
        self.assert_(student.name.middle is None)
        self.assert_(faculty.key() in student.advisors)
コード例 #2
0
ファイル: TestFaculty.py プロジェクト: tfausak/class
    def test_addRetrieveWebsite(self):
        ra = F.addResearchGroup("Beer drinkers anonymous")
        db.put(ra)

        auth1 = F.addName("Author", "One")
        auth2 = F.addName("Author", "Two")

        auth1_key = db.put(auth1)
        auth2_key = db.put(auth2)

        auths = [auth1, auth2]

        w = F.addWebsite("http://beer.com", ra, auths)

        self.assert_(w.address == "http://beer.com")
        self.assert_(w.group.name == "Beer drinkers anonymous")
        # self.assert_(len(w.authors) == 2)
        self.assert_(auth1_key in w.authors and auth2_key in w.authors)

        w_key = db.put(w)

        w = db.get(w_key)

        self.assert_(w.address == "http://beer.com")
        self.assert_(w.group.name == "Beer drinkers anonymous")
        # self.assert_(len(w.authors) == 2)
        self.assert_(auth1_key in w.authors and auth2_key in w.authors)
コード例 #3
0
        def put_name(name):
            """
			creates a name object in the database
		
			Keyword arguments:
			name -- the xml tag 'name' (of a person)
		
			return reference to Name class db object
			"""

            #cannot be None since required
            first_name = get_text(name.find('first_name'))
            last_name = get_text(name.find('last_name'))

            #can be None
            middle_name = name.find('middle_name')
            suffix = name.find('suffix')

            if middle_name is not None:
                middle_name = get_text(middle_name)
            if suffix is not None:
                suffix = get_text(suffix)

            assert first_name is not None and last_name is not None

            return Faculty3.addName(first_name, last_name, middle_name, suffix)
コード例 #4
0
ファイル: Import.py プロジェクト: saadfsti/class
		def put_name(name):
			"""
			creates a name object in the database
		
			Keyword arguments:
			name -- the xml tag 'name' (of a person)
		
			return reference to Name class db object
			"""
		
			#cannot be None since required
			first_name = get_text(name.find('first_name'))
			last_name = get_text(name.find('last_name'))
		
			#can be None
			middle_name = name.find('middle_name')
			suffix = name.find('suffix')
		
			if middle_name is not None:
				middle_name = get_text(middle_name)
			if suffix is not None:
				suffix = get_text(suffix)
		
			assert first_name is not None and last_name is not None
		
			return Faculty3.addName(first_name, last_name, middle_name, suffix)	
コード例 #5
0
ファイル: TestFaculty.py プロジェクト: tfausak/class
    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")
コード例 #6
0
ファイル: TestFaculty.py プロジェクト: tfausak/class
    def test_addRetrieveName(self):
        name = F.addName("This", "Sucks", "Really", "Bad")

        self.assert_(name.first == "This")
        self.assert_(name.last == "Sucks")
        self.assert_(name.suffix == "Bad")
        self.assert_(name.middle == "Really")

        name_key = name.key()

        name = db.get(name_key)

        self.assert_(name.first == "This")
        self.assert_(name.last == "Sucks")
        self.assert_(name.suffix == "Bad")
        self.assert_(name.middle == "Really")
コード例 #7
0
ファイル: TestFaculty.py プロジェクト: tfausak/class
    def test_addRetrieveFaculty(self):
        name = F.addName("This", "Sucks", "Really", "Bad")

        faculty = F.addFaculty(name, ["*****@*****.**", "*****@*****.**"], "Lecturer", "tsucks")

        self.assert_(faculty.username == "tsucks")
        self.assert_("*****@*****.**" in faculty.emails and "*****@*****.**" in faculty.emails)
        self.assert_(faculty.name.first == "This")
        self.assert_(faculty.name.last == "Sucks")
        self.assert_(faculty.name.suffix == "Bad")
        self.assert_(faculty.name.middle == "Really")

        faculty_key = db.put(faculty)

        faculty = db.get(faculty_key)

        self.assert_(faculty.username == "tsucks")
        self.assert_("*****@*****.**" in faculty.emails and "*****@*****.**" in faculty.emails)
        self.assert_(faculty.name.first == "This")
        self.assert_(faculty.name.last == "Sucks")
        self.assert_(faculty.name.suffix == "Bad")
        self.assert_(faculty.name.middle == "Really")
コード例 #8
0
ファイル: TestFaculty.py プロジェクト: tfausak/class
    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)
コード例 #9
0
    def post(self):
        '''
		Put all the submitted data into the data store and redirect to the person's page.
		@param self
		'''
        # Get the person's key from the query string and make it a Key object
        key = self.request.get('key')
        key = db.Key(key)

        # Get the person from the database
        person = db.get(key)

        # NAME
        name = {
            'first': self.request.get('name.first'),
            'middle': self.request.get('name.middle'),
            'last': self.request.get('name.last'),
            'suffix': self.request.get('name.suffix')
        }
        person.name = Faculty3.addName(**name)

        # USERNAME
        person.username = self.request.get('username')

        # TITLE / STATUS
        if person.kind() == 'Faculty':
            person.title = self.request.get('title')
        else:
            assert person.kind() == 'Student'
            person.status = self.request.get('status')

        # EMAILS
        emails = []
        for argument in self.request.arguments():
            if argument.startswith('email-') and self.request.get(
                    argument + '-toggle') == 'on':
                email = self.request.get(argument)
                emails.append(db.Email(email))
        person.emails = emails

        # WEBSITES
        websites = set()
        for argument in self.request.arguments():
            if argument.startswith('website-') and self.request.get(
                    argument + '-toggle') == 'on':
                address = self.request.get(argument)
                group = self.request.get(argument + '-group')
                group = db.get(group)
                website = Faculty3.addWebsite(address, group, [person.name])
                website = db.put(website)
                websites.add(website)
        person.websites = list(websites)

        # RESEARCH AREAS
        research_areas = set()
        for argument in self.request.arguments():
            if argument.startswith('research_area-') and self.request.get(
                    argument + '-toggle') == 'on':
                research_area = self.request.get(argument)
                research_area = db.Key(research_area)
                research_areas.add(research_area)
        person.research_areas = list(research_areas)

        # RESEARCH GROUPS
        research_groups = set()
        for argument in self.request.arguments():
            if argument.startswith('research_group-') and self.request.get(
                    argument + '-toggle') == 'on':
                research_group = self.request.get(argument)
                research_group = db.Key(research_group)
                research_groups.add(research_group)
        person.research_groups = list(research_groups)

        # Commit all changes to the data store and redirect to the person's page
        db.put(person)
        self.redirect('/view/person?key=' + str(key))
コード例 #10
0
ファイル: EditPerson.py プロジェクト: saadfsti/class
	def post (self):
		'''
		Put all the submitted data into the data store and redirect to the person's page.
		@param self
		'''
		# Get the person's key from the query string and make it a Key object
		key = self.request.get('key')
		key = db.Key(key)
		
		# Get the person from the database
		person = db.get(key)
		
		# NAME
		name = {
			'first' : self.request.get('name.first'),
			'middle' : self.request.get('name.middle'),
			'last' : self.request.get('name.last'),
			'suffix' : self.request.get('name.suffix')
		}
		person.name = Faculty3.addName(**name)
		
		# USERNAME
		person.username = self.request.get('username')
		
		# TITLE / STATUS
		if person.kind() == 'Faculty':
			person.title = self.request.get('title')
		else:
			assert person.kind() == 'Student'
			person.status = self.request.get('status')
		
		# EMAILS
		emails = []
		for argument in self.request.arguments():
			if argument.startswith('email-') and self.request.get(argument + '-toggle') == 'on':
				email = self.request.get(argument)
				emails.append(db.Email(email))
		person.emails = emails
		
		# WEBSITES
		websites = set()
		for argument in self.request.arguments():
			if argument.startswith('website-') and self.request.get(argument + '-toggle') == 'on':
				address = self.request.get(argument)
				group = self.request.get(argument + '-group')
				group = db.get(group)
				website = Faculty3.addWebsite(address, group, [person.name])
				website = db.put(website)
				websites.add(website)
		person.websites = list(websites)
		
		# RESEARCH AREAS
		research_areas = set()
		for argument in self.request.arguments():
			if argument.startswith('research_area-') and self.request.get(argument + '-toggle') == 'on':
				research_area = self.request.get(argument)
				research_area = db.Key(research_area)
				research_areas.add(research_area)
		person.research_areas = list(research_areas)
		
		# RESEARCH GROUPS
		research_groups = set()
		for argument in self.request.arguments():
			if argument.startswith('research_group-') and self.request.get(argument + '-toggle') == 'on':
				research_group = self.request.get(argument)
				research_group = db.Key(research_group)
				research_groups.add(research_group)
		person.research_groups = list(research_groups)
		
		# Commit all changes to the data store and redirect to the person's page
		db.put(person)
		self.redirect('/view/person?key=' + str(key))