def check_activation_email_patient(self): ''' 1) receive confirmation email 2) clicks profile activation link 3) sets a password ''' # check email messages = self.mail_stub.get_sent_messages(to=self._TEST_PATIENT_EMAIL) self.assertEqual(1, len(messages)) m = messages[0] patient = Patient.query(Patient.email == self._TEST_PATIENT_EMAIL).get() booking = Booking.query(Booking.patient == patient.key).get() self.assertEqual(m.subject, 'Rendez-vous Veosan - %s' % 'Ostéopathe') # assert that activation link is in the email body user = User.query(User.key == patient.user).get() self.assertTrue('http://localhost/user/activation/%s' % user.signup_token in m.body.payload) # click link in email activation_response = self.testapp.get('/user/activation/%s' % str(user.signup_token)) # choose a password activation_response.mustcontain('Votre rendez-vous est confirmé') activation_response.mustcontain("Fantastic Fox") booking = Booking.query(Booking.patient == patient.key).get() activation_response_form = activation_response.forms[0] activation_response_form['password'] = self._TEST_PATIENT_PASSWORD activation_response_form['password_confirm'] = self._TEST_PATIENT_PASSWORD booking_confirm_page = activation_response_form.submit() # patient email in navbar booking_confirm_page.mustcontain(self._TEST_PATIENT_EMAIL) # Title check booking_confirm_page.mustcontain('You new appointment is confirmed!')
def fetch_patients(): return Patient.query().order(Patient.last_name)
def get_patient_from_user(user): '''returns the first patient profile liked to user. Returns None if user is not a patient''' if user: return Patient.query(Patient.user == user.key).get() else: return None
def get_patient_from_email(email): return Patient.query(Patient.email == email).get()