コード例 #1
0
    def patient_confirms_latest_booking(self, date_string, time_string, new_user=True, logged_in=False):
        # check email to patient
        booking_datetime = datetime.strptime(testutil.next_monday_date_string() + " " + str(time_string), '%Y-%m-%d %H')
        french_datetime_string = format_datetime(booking_datetime, "EEEE 'le' d MMMM yyyy", locale='fr_CA') + " à " + format_datetime(booking_datetime, "H:mm", locale='fr_CA')

        english_datetime_string = format_datetime(booking_datetime, "EEEE d MMMM yyyy", locale='en') + " at " + format_datetime(booking_datetime, "H:mm", locale='en')

        
        booking_datetime = datetime.strptime(testutil.next_monday_date_string(), '%Y-%m-%d')
        booking_datetime_string = format_date(booking_datetime, format="d MMM yyyy", locale='fr_CA')
        
        booking_time = datetime.strptime(str(time_string), '%H')
        booking_time_string = format_time(booking_time, format="short", locale='fr')
        
        logging.info('French date time of booking: %s' % french_datetime_string) 
        # check that confirmation emails was sent to patient
        messages = self.mail_stub.get_sent_messages(to=self._TEST_PATIENT_EMAIL)
        patient_email_count = len(messages)
        # get last email sent
        m = messages[patient_email_count - 1]
        self.assertEqual(self._TEST_PATIENT_EMAIL, m.to)
        
        # activate account
        messages = self.mail_stub.get_sent_messages(to=self._TEST_PATIENT_EMAIL)
        
        self.assertEquals(m.subject, 'Veosan Appointment - Osteopath')
        user = db.get_user_from_email(self._TEST_PATIENT_EMAIL)
        
        # check email content
        self.assertIn('Hi', m.body.payload)
        self.assertIn('Thank you', m.body.payload)
        self.assertIn(english_datetime_string, m.body.payload)
        self.assertNotIn('None',  m.body.payload)
        
        patient = db.get_patient_from_user(user)
        bookings = db.get_bookings_for_patient(patient)        
        booking = bookings[0]
        
        if new_user:
            self.assertTrue('/login/booking/%s' % booking.key.urlsafe() in m.body.payload)
            
            response = self.testapp.get('/')
            is_french = 'Déconnexion' in response
            is_english = 'Logout' in response
            
            user_logged_in = False
            if is_english:
                user_logged_in = 'Logout' in response
            elif is_french:
                user_logged_in = 'Déconnexion' in response

    
            # click the link
            response = self.testapp.get('/login/booking/%s' % booking.key.urlsafe())


            # is user logged in?
            if not user_logged_in:
                if is_english:
                    response.mustcontain("Login to Veosan")
                elif is_french:
                    response.mustcontain("Connexion à Veosan")
                    
                login_form = response.forms['login_form']
                login_form['password'] = self._TEST_PATIENT_PASSWORD
                response = login_form.submit().follow()
            else:
                response = response.follow()
            
            response.mustcontain("Upcoming Appointments")
            response.mustcontain('Fantastic Fox')

            #response.mustcontain(booking_time_string)
            response.mustcontain(english_datetime_string)
            
            # patient email in navbar
            response.mustcontain(self._TEST_PATIENT_EMAIL)
            response.mustcontain('Logout')
コード例 #2
0
ファイル: patient.py プロジェクト: phiiil/veosan
 def render_bookings(handler, patient, provider=None, **kw):
     ''' Render a patient's bookings '''
     bookings = db.get_bookings_for_patient(patient)
     bookings = sorted(bookings, key=attrgetter('datetime'), reverse=True)
     handler.render_template('patient/booking_list.html', provider=provider, bookings=bookings, **kw)