示例#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()
示例#2
0
# 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)

import datetime
# Create Period in database
p = Period(idPeriod = 7, period = "3rd", StartDate = datetime.datetime.now(), EndDate = datetime.datetime.now(), InstructionBegins = datetime.datetime.now(), InstructionEnds = datetime.datetime.now())

# Save to database
p.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)