import model.staff
import services

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()
