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()
name = s.School
num = s.idSchool
#print out python values of school
print "Name = %s, Num = %d" % (name, num)

# Create department
d = Department(idDepartment = 2, idSchool = s, Department = "CompSci", DeptAbbrev = "CMPS") 

d.save()

# print out values
print "Department:\nDepartment ID = %d, School id = %s, Department = %s Department Abbrev = %s" % (d.idDepartment, d.idSchool, d.Department, d.DeptAbbrev)


# Create class
c = Class(idDepartment = d, idClass = 3, Class = "Software Engineering", ClassDescription = "Made to kickass")

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