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 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 get(self, consultingRoomId):
     theConsultingRoomToReturn = ConsultingRoom.get_by_key_name(consultingRoomId)
     self.response.out.write(
         self.returnObjectOrResult(
             resultCode="404", objectToReturn=theConsultingRoomToReturn, encoderForObject=ConsultingRoomEncoder()
         )
     )
 def get(self):
     listOfConsultingRooms = ConsultingRoom.all().fetch(None)
     self.response.out.write(
         self.returnObjectOrResult(
             resultCode="404", objectToReturn=listOfConsultingRooms, encoderForObject=ConsultingRoomEncoder()
         )
     )
 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 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 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 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 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'])
 def delete(self):
     for aConsultingRoom in ConsultingRoom.all().fetch(None):
         aConsultingRoom.delete()
     self.response.out.write(self.returnObjectOrResult(resultCode="201"))