Exemple #1
0
 def validate_token(self, token):
     token = User.token_model.query(User.token_model.token == token).get()
     
     user = None
     if token:
         user = User.get_by_id(int(token.user))
     
     return user
Exemple #2
0
    def delete_token(self, token, subject=None):
        token = User.token_model.query(User.token_model.token == token).get()
        user = User.get_by_id(int(token.user))
        token.key.delete()
        
        if subject == 'reset':
            user.resetpassword_token = None        
            user.put()

        return None    
Exemple #3
0
 def create_test_patient(self):
     '''
         Create a test patient (and linked user) in the datastore
     '''
     user_created, new_user = User.create_user(self._TEST_PATIENT_EMAIL, password_raw=self._TEST_PATIENT_PASSWORD, roles=[auth.PATIENT_ROLE])
     self.assertTrue(user_created)
     tp = Patient()
     tp.created_on = datetime.now()
     tp.user = new_user.key
     tp.first_name = 'Pat'
     tp.last_name = 'Patient'
     tp.email = "*****@*****.**"
     tp.telephone = '514-123-1234'
     tp.terms_agreement = True
     tp.put() 
     
     new_user.language = 'fr'
     new_user.put()
Exemple #4
0
    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!')
Exemple #5
0
def get_user_from_email(email):
    return User.query(User.auth_ids == email).get()
Exemple #6
0
def update_user(id: str, user: User) -> User:
    user.id = id
    return user
Exemple #7
0
def create_user(user: User) -> User:
    user.id = uuid4()
    return user
Exemple #8
0
from typing import List
from uuid import uuid4

import names

from data.model import User

users = [
    User(id=str(uuid4()), first_name=names.get_first_name(), last_name=names.get_last_name())
    for i in range(100)
]


def get_users() -> List[User]:
    return users


def create_user(user: User) -> User:
    user.id = uuid4()
    return user


def update_user(id: str, user: User) -> User:
    user.id = id
    return user
Exemple #9
0
def get_user_from_email(email):
    return User.query(User.auth_ids == email).get()