Пример #1
0
def run():
	
	#--------------------------------SETUP----------------------------------
	
	conn = services.getConnection()
	empName = "booking test person 1"
	
	services.deleteStaff(conn,empName)
	testEmp = model.staff.StaffMember(empName, 1, True)
	
	testEmp.flush(conn)
	
	#--------------------------------INSERT TEST-------------------------------
	
	bookingTest = model.booking.Booking(empName, "2010-12-30 13:00:00", "2010-12-30 15:00:00", model.LOC1)
	
	bookingTest.flush(conn)
	
	#-------------------------------UPDATE TEST---------------------------------
	
	
	#--------------------------------DELETE TEST--------------------------------
	
	
	#--------------------------------CLEAN UP----------------------------------
	
	services.deleteStaff(conn, empName)
	
	conn.close()
Пример #2
0
def delete(name):
	"""
	Deletes the staff member identified by their name
	"""
	results = process.ERROR_PAGE
	connection = services.getConnection()
	
	name = util.strip(name)
	
	#if the name exsits then delete it
	if services.nameExists(connection, name):
	
		services.deleteStaff(connection, name)
		results = REDIRECT	
	
	return results
Пример #3
0
def run():
    dbConn = services.getConnection()

    # clear outs existing employees
    services.deleteStaff(dbConn, "test1")
    services.deleteStaff(dbConn, "test2")

    # create a new employee
    first = model.staff.StaffMember("test1", 1, True, "street", "city", "OR", "zip", "phone")

    first.flush(dbConn)

    # check if it is created
    firstCheck = services.getStaff(dbConn, "test1")

    print "created", first
    print "found  ", firstCheck
    print "created and found ", first == firstCheck

    # update employee
    first.name = "test2"
    first.roleId = 2
    first.isActive = False
    first.street = "newStreet"
    first.city = "newCity"
    first.state = "WA"
    first.zip = "newZip"
    first.phone = "newPhone"

    first.flush(dbConn, "test1")

    secondCheck = services.getStaff(dbConn, "test2")

    print "updated", first
    print "found  ", secondCheck
    print "updated and found ", first == secondCheck

    # delete employee
    services.deleteStaff(dbConn, "test2")

    thirdCheck = services.getStaff(dbConn, "test2")

    print "deleted and gone ", thirdCheck == None

    dbConn.close()
Пример #4
0
def run():
	
	#YYYY-MM-DD HH:MM:SS
	
	#--------------------------SETUP------------------------------------------
	conn = services.getConnection()
	staff = [ model.staff.StaffMember("test1", 1, False), model.staff.StaffMember("test2", 1, True), model.staff.StaffMember("test3", 2, True) ]
	apps = [ model.appointment.Appointment("2010-12-25 11:00:00", "test1", "Albany"),
			model.appointment.Appointment("2010-12-23 00:00:00", "test1", "Corvallis"),
			model.appointment.Appointment("2010-12-21 00:00:00", "test2", "Albany"),
			model.appointment.Appointment(util.toDatetime("2010-12-25 00:00:00"), "test3", "Albany"),
			model.appointment.Appointment("2010-12-24 00:00:00", "test3", "Corvallis"),
			model.appointment.Appointment("2010-11-24 00:00:00", "test3", "Corvallis") ]
	
	objs = []

	for a in apps:
		services.deleteAppointment(conn, a.time, a.staffName)
		
	for s in staff:
		services.deleteStaff(conn, s.name)

	for s in staff:
		objs.append(s)
	
	for a in apps:
		objs.append(a)
		
	for o in objs:
		o.flush(conn)
	
	#-----------------------------ALL STAFF-----------------------------------

	#all staff
	results = filterList( services.getAllStaff(conn), staff )
	print "all staff", len(results) == 3
	
	#only role 1
	results = filterList( services.getAllStaff(conn, roleId = 1), staff )
	print "role 1 staff", len(results) == 2
		
	#only active
	results = filterList( services.getAllStaff(conn, active=True), staff )
	print "active staff", len(results) == 2
	
	#only inactive, role 1
	results = filterList( services.getAllStaff(conn, active=False, roleId = 1), staff )
	print "inactive, role 1 staff", len(results) == 1
	

	#------------------------------ALL APPOINTMENTS---------------------------
	
	#all appointments
	results = filterList( services.getAppointments(conn, util.startOfWeek(util.toDatetime("2010-12-25 00:00:00"))), apps )
	print "all appointments", len(results) == 5
	
	#only role 1
	results = filterList( services.getAppointments(conn, util.startOfWeek(util.toDatetime("2010-12-25 00:00:00")), roleId = 1), apps )
	print "role 1 appointments", len(results) == 3
	
	#only Albany
	results = filterList( services.getAppointments(conn, util.startOfWeek(util.toDatetime("2010-12-25 00:00:00")), location = "Albany"), apps )
	print "Albany appointments", len(results) == 3

	#only Corvallis role 2
	results = filterList( services.getAppointments(conn, util.startOfWeek(util.toDatetime("2010-12-25 00:00:00")), location = "Corvallis", roleId = 2), apps )
	print "role 2 corvallis appointments", len(results) == 1
	
	#---------------------------------ROLES-------------------------------------
	print "3 Roles found", len( services.getRoles(conn) ) == 3
	
	#---------------------------CLEAN UP--------------------------------------
	for a in apps:
		services.deleteAppointment(conn, a.time, a.staffName)
		
	for s in staff:
		services.deleteStaff(conn, s.name)