def testInsertOneSchedule(self): aDateFrom = datetime.date(year=2014, month=4, day=27) aDateTo = datetime.date(year=2014, month=7, day=27) anAppointmentLength = datetime.time(minute=20) aProHouse = Professional(key_name="123", name="Gregory", lastName="House", email="*****@*****.**", licenseNumber=123) aProHouse.put() aConsultingRoom = ConsultingRoom(key_name="1", description="Consultorio 1", identification="1") aConsultingRoom.put() aSchedule = Schedule(dateFrom=aDateFrom, dateTo=aDateTo, appointmentLength=anAppointmentLength, professional=aProHouse, consultingRoom=aConsultingRoom) aSchedule.put() self.assertEqual(1, len(Schedule.all().fetch(None)))
def delete(self, theProfessionalId): theProfessionalToDelete = Professional.get_by_key_name(theProfessionalId) if theProfessionalToDelete is None: resultCode = "404" else: theProfessionalToDelete.delete() resultCode = "200" self.response.out.write(self.returnObjectOrResult(resultCode=resultCode))
def testInsertTwoProAndDeleteOne(self): aProHouse = Professional(key_name="123", name="Gregory", lastName="House", email="*****@*****.**", licenseNumber=123) aProWilson = Professional(key_name="321", name="James", lastName="Wilson", email="*****@*****.**", licenseNumber=321) aProHouse.put() aProWilson.put() drHouse = Professional.get_by_key_name(str(aProHouse.licenseNumber)) drHouse.delete() self.assertEqual(1, len(Professional.all().fetch(None)))
def put(self, theProfessionalId): theProfessionalToUpdate = Professional.get_by_key_name(theProfessionalId) if theProfessionalToUpdate is None: resultCode = "304" else: anUpdateProfessional = ProfessionalDecoder().decode(self.request.body) theProfessionalToUpdate.name = anUpdateProfessional.name theProfessionalToUpdate.lastName = anUpdateProfessional.lastName theProfessionalToUpdate.email = anUpdateProfessional.email theProfessionalToUpdate.put() resultCode = "200" self.response.out.write(self.returnObjectOrResult(resultCode=resultCode))
def get(self, theProfessionalId): theProfessionalToReturn = Professional.get_by_key_name(theProfessionalId) self.response.out.write(self.returnObjectOrResult( resultCode="404", objectToReturn=theProfessionalToReturn, encoderForObject=ProfessionalEncoder()))
def delete(self): for doc in Professional.all().fetch(None): Professional.delete(doc) self.response.out.write(self.returnObjectOrResult(resultCode="200"))
def get(self): listOfProfessional = Professional.all().fetch(None) self.response.out.write(self.returnObjectOrResult( resultCode="404", objectToReturn=listOfProfessional, encoderForObject=ProfessionalEncoder()))
def professionalFromDBHook(self, dictionary): return Professional.get_by_key_name(str(dictionary['licenseNumber']))
def testInsertAndGetOneProfessional(self): aProWilson = Professional(key_name="321", name="James", lastName="Wilson", email="*****@*****.**", licenseNumber=321) aProWilson.put() drWilson = Professional.get_by_key_name(str(aProWilson.licenseNumber)) self.assertEquals(aProWilson.name, drWilson.name)
def testInsertOneProfessional(self): aProHouse = Professional(key_name="123", name="Gregory", lastName="House", email="*****@*****.**", licenseNumber=123) aProHouse.put() self.assertEqual(1, len(Professional.all().fetch(None)))