def testInsertOneConsultingAndChangeDescription(self): theConsulting123 = ConsultingRoom(key_name="123", description="Consultorio123", identification="123") theConsulting123.put() theConsulting123 = ConsultingRoom.get_by_key_name(theConsulting123.identification) theConsulting123.description = "Nueva descripcion" theConsulting123.put() theConsulting123 = ConsultingRoom.get_by_key_name(theConsulting123.identification) self.assertEqual("Nueva descripcion", theConsulting123.description)
def get(self, consultingRoomId): theConsultingRoomToReturn = ConsultingRoom.get_by_key_name(consultingRoomId) self.response.out.write( self.returnObjectOrResult( resultCode="404", objectToReturn=theConsultingRoomToReturn, encoderForObject=ConsultingRoomEncoder() ) )
def testInsertOneConsultingChangeDescriptionAndIsOnlyOneConsulting(self): theConsulting123 = ConsultingRoom(key_name="123", description="Consultorio123", identification="123") theConsulting123.put() theConsulting123 = ConsultingRoom.get_by_key_name(theConsulting123.identification) theConsulting123.description = "Nueva descripcion" theConsulting123.put() self.assertEqual(1, len(ConsultingRoom.all().fetch(None)))
def delete(self, consultingRoomId): theConsultingRoomToDelete = ConsultingRoom.get_by_key_name(consultingRoomId) if theConsultingRoomToDelete is None: resultCode = "404" else: theConsultingRoomToDelete.delete() resultCode = "200" self.response.out.write(self.returnObjectOrResult(resultCode=resultCode))
def testOneConsultingWithSameKeyNameOverWriteThePreviousInsert(self): theConsulting123 = ConsultingRoom(key_name="123", description="Consultorio123", identification="123") theConsulting123.put() otherConsulting123 = ConsultingRoom(key_name="123", description="OtroConsultorio123", identification="123") otherConsulting123.put() theConsultingFromDB = ConsultingRoom.get_by_key_name(theConsulting123.identification) self.assertNotEqual(theConsulting123.description, theConsultingFromDB.description)
def put(self, consultingRoomId): theConsultingRoomToUpdate = ConsultingRoom.get_by_key_name(consultingRoomId) if theConsultingRoomToUpdate is None: resultCode = "304" else: anUpdateConsultingRoom = ConsultingRoomDecoder().decode(self.request.body) theConsultingRoomToUpdate.description = anUpdateConsultingRoom.description theConsultingRoomToUpdate.put() resultCode = "200" self.response.out.write(self.returnObjectOrResult(resultCode=resultCode))
def testInsertOneConsultingRoomAndGet(self): theConsulting123 = ConsultingRoom(key_name="123", description="Consultorio123", identification="123") theConsulting123.put() theConsulting123FromDB = ConsultingRoom.get_by_key_name(theConsulting123.identification) self.assertEqual(theConsulting123.identification, theConsulting123FromDB.identification)
def consultingFromDBHook(self, dictionary): return ConsultingRoom.get_by_key_name(key_names=dictionary['identification'])