Example #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()
c.save()

# print out values
print "Class:\nDept = %s, Class = %s, Class = %s, Class Description = %s" % (c.idDepartment, c.idClass, c.Class, c.ClassDescription)

# Create prerequisites
pre = Prerequisite(idPrereq = 4, ClassID = c)

pre.save()

# print out values
print "Prerequisite:\nPrereq ID = %d, Class = %s" % (pre.idPrereq, pre.ClassID)

#Create Building
b = Building(idBuilding = 5, BldgName = "Baskin Engineering")

#Save
b.save()

# print out values
print "Building:\nBuilding = %s, BuildingID = %d" % (b.BldgName, b.idBuilding)

# Create Room
r = Room(idBuilding = b, idRoom = 6, RoomNumber = "BE105", Type = "Comp Lab", RoomName = "Home")

# Save to Database
r.save()

# print out values from database
print "Room:\nRoomID = %d, Building = %s, RoomNumber = %s, Type = %s, Roomname = %s" % (r.idRoom, r.idBuilding, r. RoomNumber, r.Type, r.RoomName)