Beispiel #1
0
	def test_saveData(self):
		# Create School in Database
		s = School(idSchool = 1, School = "UC Santa Cruz")
		# Save to Database
		s.save()
		d = Department(idSchool = s, idDepartment = 1, Department = "CompSci", DeptAbbrev = "CMPS") 
		d.save()
		c1 = Class(idClass = 1, idDepartment = d, Class = "CMPS 115", ClassDescription = "Kickin ass")
		c1.Lab = False 
		c1.SeatNum = 45
		c2 = Class(idClass = 2, idDepartment = d, Class = "CMPS 130", ClassDescription = "Meh")
		c2.Lab = False
		c2.SeatNum = 45
	
		c1.save()
		c2.save()
	
		b = Building(idBuilding = 1, BldgName = "BE")
	
		b.save()
	
	
		r1 = Room(idBuilding = b, idRoom = 1, RoomNumber = "BE105", Type = "Lab", RoomName = "Home")
		r2 = Room(idBuilding = b, idRoom = 2, RoomNumber = "BE104", Type = "Not Lab", RoomName = "HomeJr")
	
		r1.save()
		r2.save()
	
		l1 = Lecturer(idLecturer = 1, Status = "Active", Name = "Linda Werner", Comment = "Currently teaching CS115", idDepartment = d)
		l2 = Lecturer(idLecturer = 2, Status = "Active", Name = "Patrick Tantalo", Comment = "Not teaching", idDepartment = d)
	
		l1.save()
		l2.save()
	
		p1 = Period(idPeriod = 1, period = "first", StartDate = date.today(), EndDate = date.today(), InstructionBegins = date.today(), InstructionEnds = date.today())
		p2 = Period(idPeriod = 2, period = "Second", StartDate = date.today(), EndDate = date.today(), InstructionBegins = date.today(), InstructionEnds = date.today())
		p1.save()
		p2.save()
	
		cc1 = ClassInstance(idClass = c1, idClassInstance = 1, idPeriod = p1, ClassTime = "morning", Section = "Yes", idLecturer = l1, LecturerOfficeHours = "Afternoon", TAOfficeHours = "Night", idTA = 1, idBuilding = b, idRoom = r1)
		cc2 = ClassInstance(idClass = c2, idClassInstance = 2, idPeriod = p2, ClassTime = "morning", Section = "Yes", idLecturer = l2, LecturerOfficeHours = "Afternoon", TAOfficeHours = "Night", idTA = 1, idBuilding = b, idRoom = r2)
		
		cc1.save()
		cc2.save()
# Print out values from database
print "Period:\nPeriod ID = %d, Period = %s, Start = %s, End = %s, Begining = %s, last day = %s" % (p.idPeriod, p.period, p.StartDate, p.EndDate, p.InstructionBegins, p.InstructionEnds)

# Create Lecturer
l = Lecturer(idLecturer = 8, Status = "Teaching", Name = "Linda Werner", Comment = "Works in San Jose on Tues/Thurs", idDepartment = d)

l.save

# Prints out values of Lecturer
print "Lecturer:\nLecturer ID = %d, Status = %s, Name = %s, Comment = %s, Dept = %s" % (l.idLecturer, l.Status, l.Name, l.Comment, l.idDepartment)


#Creates Class Instance
ci = ClassInstance(idClass = c, idClassInstance = 10, idPeriod = p, ClassTime = "Noon", Section = "yes", idLecturer = l, LecturerOfficeHours = "Afternoon", TAOfficeHours = "Morning", idTA = 11, idBuilding = b, idRoom = r)

ci.save()

#print out valeus of Class instance
print "Class Instance:\n Class = %s, Class Instance = %d, Period = %s, Time = %s, Section = %s, Lecturer = %s, Lecturer Office Hours = %s, TA office hours = %s, TA = %d, Building = %s, Room = %s" % (ci.idClass, ci.idClassInstance, ci.idPeriod, ci.ClassTime, ci.Section, ci.idLecturer, ci.LecturerOfficeHours, ci.TAOfficeHours, ci.idTA, ci.idBuilding, ci.idRoom)

#Creates Class Lab
cl = ClassLab(idClassInstance = ci, idClassLab = 12, LabName = "BE104", LabTime = "Noon", idRoom = r, idBuilding = b)

cl.save()

print "Class Lab:\nClass Instance = %s, Class Lab ID = %d, Lab name = %s, Lab time = %s, Room = %s, Building = %s" % (cl.idClassInstance, cl.idClassLab, cl.LabName, cl.LabTime, cl.idRoom, cl.idBuilding)

#Creates Person
p = Person(idPerson = 14, FName = "Erik", MInitial = 'Q', LName = "Steggall", Suffix = "None", Prefix = "None")

p.save()