示例#1
0
文件: base.py 项目: deltron/veosan
    def modify_provider_address_action(self):        
        # request the address page
        response = self.testapp.get('/provider/address/%s' % self._TEST_PROVIDER_VANITY_URL)
        
        address_form = response.forms[0] # address form
        
        # verify form contains correct info
        self.assertEqual(address_form['title'].value, u"mr")
        self.assertEqual(address_form['first_name'].value, u"Fantastic")
        self.assertEqual(address_form['last_name'].value, u"Fox")
        self.assertEqual(address_form['phone'].value, self._TEST_PROVIDER_TELEPHONE)
        self.assertEqual(address_form['address'].value, u"123 Main St.")
        self.assertEqual(address_form['city'].value, u"Westmount")
        self.assertEqual(address_form['postal_code'].value, u"H1B2C3")

        provider = db.get_provider_from_email(self._TEST_PROVIDER_EMAIL)
        
        # iterate over every field item, find the match in the provider object and check its equality
        # with database
        for k in iter(address_form.fields):
            if hasattr(provider, str(k)):
                self.assertEquals(address_form[k].value, getattr(provider, k))

        # make some changes to the form
        address_form['title'] = u"mrs"
        address_form['first_name'] = u"Linda"
        address_form['last_name'] = u"Otter"
        address_form['phone'] = u"555-987-6543"
        address_form['address'] = u"321 Primary St."
        address_form['city'] = u"Outremont"
        address_form['postal_code'] = u"C4B5C6"


        # submit it
        response = address_form.submit()
        response.mustcontain("Vos modifications ont été enregistrées.")

        # check values in database
        provider = db.get_provider_from_email(self._TEST_PROVIDER_EMAIL)
        
        # iterate over every field item, find the match in the provider object and check its equality
        # possible we miss something here?
        for k in iter(address_form.fields):
            if hasattr(provider, str(k)):
                self.assertEquals(address_form[k].value, getattr(provider, k))

        # go back to the admin page, check the name is updated
        self.login_as_admin()
        response = self.testapp.get('/admin/providers')
        response.mustcontain("Otter")
        response.mustcontain("Linda")
        response.mustcontain("*****@*****.**")
示例#2
0
文件: base.py 项目: deltron/veosan
    def provider_add_services_action(self, duration=45):
        # get the provider key
        provider = db.get_provider_from_email(self._TEST_PROVIDER_EMAIL)
        
        # post 
        profile_response = self.testapp.get('/provider/profile/%s' % provider.vanity_url)
        service_form = profile_response.forms['service_form']
        service_form['description'] = 'Diagnosis'        
        service_form['cost'] = 85
        service_form['duration'] = duration
        
        response = service_form.submit().follow()
        response.mustcontain("Diagnosis")
        response.mustcontain("85,00 $")
        response.mustcontain("%s minutes" % duration)

        
        
        
        
        
        
        
        
                
示例#3
0
    def fill_new_provider_address_correctly_action(self):
        # request the address page
        response = self.testapp.get('/provider/address/%s' % self._TEST_PROVIDER_VANITY_URL)
        #response.showbrowser()
        address_form = response.forms['address_form'] # address form
        
        # fill out the form
        address_form['title'] = u"mr"
        address_form['first_name'] = u"Fantastic"
        address_form['last_name'] = u"Fox"
        address_form['phone'] = self._TEST_PROVIDER_TELEPHONE
        address_form['address'] = u"123 Main St."
        address_form['city'] = u"Westmount"
        address_form['postal_code'] = u"H1B2C3"

        
        # submit it
        response = address_form.submit()
        response.mustcontain("Vos modifications ont été enregistrées.")

        # check values in database
        provider = db.get_provider_from_email(self._TEST_PROVIDER_EMAIL)
        
        # iterate over every field item, find the match in the provider object and check its equality
        # possible we miss something here?
        for k in iter(address_form.fields):
            if hasattr(provider, str(k)):
                self.assertEquals(address_form[k].value, getattr(provider, k))

        # go back to the admin page, check the name is updated
        self.login_as_admin()
        response = self.testapp.get('/admin/providers')
        response.mustcontain("Fox")
        response.mustcontain("*****@*****.**")
        self.logout_admin()
示例#4
0
 def get(self, prospect_id = None):
     # set prospect
     if prospect_id:
         self.log_prospect(prospect_id)
         prospect = db.get_prospect_from_prospect_id(prospect_id)
         
         # check if the prospect actually signed up
         if prospect:
             provider = db.get_provider_from_email(prospect.email)
             
             if provider:
                 language = prospect.language
                 redirect_url = "/" + language + "/signup/provider"
                 self.redirect(str(redirect_url))
             else:
                 # populate form with prospect info
                 provider_signup_form2 = forms.user.ProviderSignupForm2().get_form(obj=prospect, request_webob=self.request)
                 
                 # check the agreement by default
                 provider_signup_form2['terms_agreement'].data = True
                 
                 # on to the next step
                 self.render_template('user/signup_provider_2.html', provider_signup_form2=provider_signup_form2)
         else:
             self.redirect('/en/signup/provider')
     else:
         self.redirect('/en/signup/provider')
示例#5
0
    def test_admin_change_password_for_provider(self):
        # setup a provider
        self.self_signup_provider()
        # login as admin
        self.login_as_admin()
        # get the provider key
        provider = db.get_provider_from_email(self._TEST_PROVIDER_EMAIL)
        # request the admin page
        response = self.testapp.get('/admin/provider/admin/%s' %
                                    provider.vanity_url)

        password_form = response.forms['change_password']
        password_form['password'] = '******'
        password_form.submit()

        self.logout_admin()
        self.logout_provider()

        # login with old password
        login_page = self.testapp.get('/login')

        is_french = 'Connexion' in login_page
        is_english = 'Login' in login_page

        if is_english:
            login_page.mustcontain(u"Login")
        elif is_french:
            login_page.mustcontain(u"Connexion")

        login_form = login_page.forms[0]
        login_form['email'] = self._TEST_PROVIDER_EMAIL
        login_form['password'] = self._TEST_PROVIDER_PASSWORD
        login_error = login_form.submit()

        login_error.mustcontain("Login failed. Try again.")

        login_form = login_error.forms[0]
        login_form['email'] = self._TEST_PROVIDER_EMAIL
        login_form['password'] = '******'
        login_success = login_form.submit().follow()

        # default page for provider after login is welcome
        # (in french because profile is set to french)
        login_success.mustcontain("Profil")
        login_success.mustcontain(self._TEST_PROVIDER_EMAIL)
        login_success.mustcontain("Bienvenue!")
        login_success.mustcontain("Comment naviguer sur le site")

        # check the event log
        #self.assert_msg_in_log("Provider Logged In")

        return response
示例#6
0
    def test_admin_change_password_for_provider(self):
        # setup a provider
        self.self_signup_provider()
        # login as admin
        self.login_as_admin()
        # get the provider key
        provider = db.get_provider_from_email(self._TEST_PROVIDER_EMAIL)
        # request the admin page
        response = self.testapp.get('/admin/provider/admin/%s' % provider.vanity_url)
        
        password_form = response.forms['change_password']
        password_form['password'] = '******'
        password_form.submit()
        
        self.logout_admin()
        self.logout_provider()
        
        # login with old password
        login_page = self.testapp.get('/login')
        
        is_french = 'Connexion' in login_page
        is_english = 'Login' in login_page
        
        if is_english:
            login_page.mustcontain(u"Login")
        elif is_french:
            login_page.mustcontain(u"Connexion")
            
        login_form = login_page.forms[0]
        login_form['email'] = self._TEST_PROVIDER_EMAIL
        login_form['password'] = self._TEST_PROVIDER_PASSWORD
        login_error = login_form.submit()
        
        login_error.mustcontain("Login failed. Try again.")
        
        login_form = login_error.forms[0]
        login_form['email'] = self._TEST_PROVIDER_EMAIL
        login_form['password'] = '******'
        login_success = login_form.submit().follow()

        # default page for provider after login is welcome
        # (in french because profile is set to french)
        login_success.mustcontain("Profil")
        login_success.mustcontain(self._TEST_PROVIDER_EMAIL)
        login_success.mustcontain("Bienvenue!")
        login_success.mustcontain("Comment naviguer sur le site")        

        # check the event log
        #self.assert_msg_in_log("Provider Logged In")

        return response
示例#7
0
 def __call__(self, form, field):
     email = field.data
 
     if email:
         # try to fetch a provider with this email address
         provider = db.get_provider_from_email(email)
         
         if provider:
             # taken
             raise ValidationError(self.message)
 
         else:
             #available
             pass
示例#8
0
    def provider_schedule_set_one_timeslot_action(self, day='monday', start_time=9, end_time=12):

        # get the provider key
        provider = db.get_provider_from_email(self._TEST_PROVIDER_EMAIL)
        
        # request the schedule page
        response = self.testapp.get('/provider/schedule/%s' % provider.vanity_url)
        
        # Check that schedule is empty

        # Add an available schedule Monday morning 9-12
        response = self.testapp.get('/provider/schedule/%s/add/%s/%s' % (provider.vanity_url, day, start_time))
        
        schedule_form = response.forms['schedule_form']
        
        # check the form selects are filled with values
        
        schedule_form['day'] = day
        schedule_form['start_time'] = start_time
        schedule_form['end_time'] = end_time
        response = schedule_form.submit().follow()
        
        provider = db.get_provider_from_email("*****@*****.**")
        
        # check one schedule was saved in the database
        schedule_count = provider.get_schedules().count()
        self.assertGreater(schedule_count , 0, 'Provider should have at least one schedule')
        self.assertIn('%s:00<br>\n\t\t\t\t\t\t-<br>\n\t\t\t\t\t\t%s:00' % (start_time, end_time), str(response))
        
        # check if square for day is green
        row_span_string = str(end_time - start_time)
        monday_morning_td = response.html.find('td', attrs={'rowspan': row_span_string})
        self.assertIsNotNone(monday_morning_td, 'schedule td with rowspan %s does not exist' % row_span_string)

        monday_morning_a = monday_morning_td.find('a')
        self.assertIsNotNone(monday_morning_a, 'schedule button does not exist')
示例#9
0
 def test_admin_sees_all_tabs_for_provider(self):
     # setup a provider
     self.self_signup_provider()
     # login as admin
     self.login_as_admin()
     # get the provider key
     provider = db.get_provider_from_email(self._TEST_PROVIDER_EMAIL)
     # request the address page
     response = self.testapp.get('/provider/bookings/%s' % provider.vanity_url)
     # patient name in navbar
     response.mustcontain('Administration')
     response.mustcontain('Rendez-vous')
     response.mustcontain('Horaire')
     response.mustcontain('Profil')
     response.mustcontain('Adresse')
示例#10
0
    def post(self, vanity_url=None, operation=None, provider_key=None):
        provider = db.get_provider_from_vanity_url(vanity_url)
        
        if operation == 'invite' :
            form = ProviderInviteForm().get_form(self.request.POST)
            if form.validate():
                invite = Invite()
                form.populate_obj(invite)

                # check if the target email is an existing user
                target_provider = db.get_provider_from_email(invite.email)
                if target_provider: 
                    # already a member, just make a connection request
                    self.redirect('/%s/connect' % target_provider.vanity_url)
                
                else:
                    # new person
                    # associate provider to invite
                    invite.provider = provider.key
                    
                    # create a token for this invite that will be used to pre-populate the signup form
                    invite.token = self.create_token_oldstyle(invite.email)
                    
                    # save
                    invite.put()
                    
                    # create an invite url
                    url_obj = urlparse.urlparse(self.request.url)
                    invite_url = urlparse.urlunparse((url_obj.scheme, url_obj.netloc, '/invite/' + invite.token, '', '', ''))
                    logging.info('(ProviderNetworkHandler.post) unique invite URL:' + invite_url)
        
                    # send the actual email...
                    mail.email_invite(self.jinja2, invite, invite_url)
                    
                    # all good
                    msg = _("Invitation sent to")
                    message = msg + " %s %s" % (invite.first_name, invite.last_name)
                    
                    # new form for next invite
                    provider_invite_form = ProviderInviteForm().get_form()
                    self.render_template("provider/network.html", success_message=message, provider=provider, provider_invite_form=provider_invite_form)
            else:
                self.render_template("provider/network.html", provider=provider, provider_invite_form=form)
        else:
            # post unknown operation
            
            provider_invite_form = ProviderInviteForm().get_form()
            self.render_template("provider/network.html", success_message=message, provider=provider, provider_invite_form=provider_invite_form)
示例#11
0
 def test_admin_sees_all_tabs_for_provider(self):
     # setup a provider
     self.self_signup_provider()
     # login as admin
     self.login_as_admin()
     # get the provider key
     provider = db.get_provider_from_email(self._TEST_PROVIDER_EMAIL)
     # request the address page
     response = self.testapp.get('/provider/bookings/%s' %
                                 provider.vanity_url)
     # patient name in navbar
     response.mustcontain('Administration')
     response.mustcontain('Rendez-vous')
     response.mustcontain('Horaire')
     response.mustcontain('Profil')
     response.mustcontain('Adresse')
示例#12
0
    def post(self, vanity_url=None):
        provider = db.get_provider_from_vanity_url(vanity_url)
        target_provider_email = self.request.get('email')
        if target_provider_email:
            target_provider = db.get_provider_from_email(target_provider_email)
            
            provider_network_connection = ProviderNetworkConnection()
            provider_network_connection.source_provider = provider.key
            provider_network_connection.target_provider = target_provider.key
            provider_network_connection.confirmed = True
            provider_network_connection.rejected = False
            provider_network_connection.forced_by_admin = True
            provider_network_connection.put()

            logging.info("(ProviderForceFriendsHandler) Provider %s forcing connection to %s" % (provider.email, provider.vanity_domain))

        self.redirect('/admin/provider/admin/' + provider.vanity_url)
示例#13
0
    def post(self, vanity_url=None):
        provider = db.get_provider_from_vanity_url(vanity_url)
        target_provider_email = self.request.get('email')
        if target_provider_email:
            target_provider = db.get_provider_from_email(target_provider_email)

            provider_network_connection = ProviderNetworkConnection()
            provider_network_connection.source_provider = provider.key
            provider_network_connection.target_provider = target_provider.key
            provider_network_connection.confirmed = True
            provider_network_connection.rejected = False
            provider_network_connection.forced_by_admin = True
            provider_network_connection.put()

            logging.info(
                "(ProviderForceFriendsHandler) Provider %s forcing connection to %s"
                % (provider.email, provider.vanity_domain))

        self.redirect('/admin/provider/admin/' + provider.vanity_url)
示例#14
0
    def fill_new_provider_profile_correctly_action(self, as_admin=True):
        
        # request the address page
        response = self.testapp.get('/provider/profile/%s' % self._TEST_PROVIDER_VANITY_URL)
         
        profile_form = response.forms[0] # address form
        
        # fill out the form        
        profile_form.set('practice_sites', True, 0) # onsite visits


        profile_form['bio'] = "Areas of interest include treatment and management of spinal conditions with an emphasis on manual therapy and rehabilitative exercise."        
        profile_form['quote'] = "The quick brown fox jumped over the lazy dog."

        # submit it
        response = profile_form.submit()
        
        # go back to the profile page
        
        response = self.testapp.get('/provider/profile/%s' % self._TEST_PROVIDER_VANITY_URL)

        response.mustcontain("Areas of interest include treatment and management")
        response.mustcontain("The quick brown fox jumped over the lazy dog")

        # TODO - switch to Beautiful Soup to parse HTML?
        response.mustcontain('input checked id="practice_sites-0" name="practice_sites" type="checkbox" value="onsite"')        
        
        # check values in database
        provider = db.get_provider_from_email("*****@*****.**")
        
        # iterate over every field item, find the match in the provider object and check its equality
        # possible we miss something here?
        for k in iter(profile_form.fields):
            if hasattr(provider, str(k)):
                value = getattr(provider, k)
                if isinstance(value, str):
                    self.assertEquals(profile_form[k].value, value)
                #elif isinstance(value, list):   
                    # TODO: how to check this automatically?
                    #self.assertIn(profile_form[k].values, value)
        
                
        self.assertIn('onsite', provider.practice_sites)
示例#15
0
    def test_signup_vanity_name_every_accent(self):
        ''' Basic signup process for a new provider '''
        response = self.testapp.post('/fr/signup/provider')

        signup_form = response.forms['provider_signup_form']
        signup_form['first_name'] = 'Renée'
        signup_form['last_name'] = 'St-Vilàîèöêûç'
        signup_form['email'] = self._TEST_PROVIDER_EMAIL
        response = signup_form.submit()

        signup_form2 = response.forms['provider_signup_form2']
        signup_form2['category'] = 'osteopath'
        signup_form2['password'] = self._TEST_PROVIDER_PASSWORD
        signup_form2['password_confirm'] = self._TEST_PROVIDER_PASSWORD
        signup_form2['terms_agreement'] = 'True'

        profile_response = signup_form2.submit().follow()
        profile_response.mustcontain("Bienvenue")

        provider = db.get_provider_from_email(self._TEST_PROVIDER_EMAIL)
        self.assertEqual(provider.vanity_url, 'reneestvilaieoeuc')
示例#16
0
    def test_admin_generate_claim_url_for_provider(self):
        # setup a provider
        self.self_signup_provider()
        # login as admin
        self.login_as_admin()
        # get the provider key
        provider = db.get_provider_from_email(self._TEST_PROVIDER_EMAIL)
        # request the admin page
        response = self.testapp.get('/admin/provider/admin/%s' %
                                    provider.vanity_url)

        # generate a claim url
        response = self.testapp.get('/admin/provider/generateclaim/%s' %
                                    provider.vanity_url)
        response = response.follow()

        user = db.get_user_from_email(self._TEST_PROVIDER_EMAIL)

        response.mustcontain(user.claim_url)

        self.logout_admin()
        self.logout_provider()

        claim_page = self.testapp.get(user.claim_url)

        login_form = claim_page.forms[0]
        login_form['email'] = self._TEST_PROVIDER_EMAIL
        login_form['password'] = self._TEST_PROVIDER_PASSWORD
        login_form['password_confirm'] = self._TEST_PROVIDER_PASSWORD

        login_success = login_form.submit().follow()

        # default page for provider after login is welcome
        # (in french because profile is set to french)
        login_success.mustcontain("Profil")
        login_success.mustcontain(self._TEST_PROVIDER_EMAIL)
        login_success.mustcontain("Bienvenue!")
        login_success.mustcontain("Comment naviguer sur le site")
示例#17
0
    def test_admin_generate_claim_url_for_provider(self):
        # setup a provider
        self.self_signup_provider()
        # login as admin
        self.login_as_admin()
        # get the provider key
        provider = db.get_provider_from_email(self._TEST_PROVIDER_EMAIL)
        # request the admin page
        response = self.testapp.get('/admin/provider/admin/%s' % provider.vanity_url)
                
        # generate a claim url
        response = self.testapp.get('/admin/provider/generateclaim/%s' % provider.vanity_url)
        response = response.follow()
        
        user = db.get_user_from_email(self._TEST_PROVIDER_EMAIL)
        
        response.mustcontain(user.claim_url)

        self.logout_admin()
        self.logout_provider()
        
        claim_page = self.testapp.get(user.claim_url)
                    
        login_form = claim_page.forms[0]
        login_form['email'] = self._TEST_PROVIDER_EMAIL
        login_form['password'] = self._TEST_PROVIDER_PASSWORD
        login_form['password_confirm'] = self._TEST_PROVIDER_PASSWORD
        
        login_success = login_form.submit().follow()

        # default page for provider after login is welcome
        # (in french because profile is set to french)
        login_success.mustcontain("Profil")
        login_success.mustcontain(self._TEST_PROVIDER_EMAIL)
        login_success.mustcontain("Bienvenue!")
        login_success.mustcontain("Comment naviguer sur le site")        
示例#18
0
    def test_signup_vanity_name_collision(self):
        ''' Basic signup process for a new provider '''
        response = self.testapp.post('/fr/signup/provider')

        signup_form = response.forms['provider_signup_form']
        signup_form['first_name'] = 'first'
        signup_form['last_name'] = 'last'
        signup_form['email'] = self._TEST_PROVIDER_EMAIL
        response = signup_form.submit()

        signup_form2 = response.forms['provider_signup_form2']
        signup_form2['category'] = 'osteopath'
        signup_form2['password'] = self._TEST_PROVIDER_PASSWORD
        signup_form2['password_confirm'] = self._TEST_PROVIDER_PASSWORD
        signup_form2['terms_agreement'] = 'True'

        profile_response = signup_form2.submit().follow()
        profile_response.mustcontain("Bienvenue")

        self.logout_provider()

        response = self.testapp.post('/fr/signup/provider')

        signup_form = response.forms['provider_signup_form']
        signup_form['first_name'] = 'first'
        signup_form['last_name'] = 'last'
        signup_form['email'] = '*****@*****.**'
        response = signup_form.submit()

        signup_form2 = response.forms['provider_signup_form2']
        signup_form2['category'] = 'osteopath'
        signup_form2['password'] = self._TEST_PROVIDER_PASSWORD
        signup_form2['password_confirm'] = self._TEST_PROVIDER_PASSWORD
        signup_form2['terms_agreement'] = 'True'

        profile_response = signup_form2.submit().follow()
        profile_response.mustcontain("Bienvenue")

        provider = db.get_provider_from_email('*****@*****.**')
        self.assertEqual(provider.vanity_url, 'firstlast1')

        self.logout_provider()

        response = self.testapp.post('/fr/signup/provider')

        signup_form = response.forms['provider_signup_form']
        signup_form['first_name'] = 'first'
        signup_form['last_name'] = 'last'
        signup_form['email'] = '*****@*****.**'
        response = signup_form.submit()

        signup_form2 = response.forms['provider_signup_form2']
        signup_form2['category'] = 'osteopath'
        signup_form2['password'] = self._TEST_PROVIDER_PASSWORD
        signup_form2['password_confirm'] = self._TEST_PROVIDER_PASSWORD
        signup_form2['terms_agreement'] = 'True'

        profile_response = signup_form2.submit().follow()
        profile_response.mustcontain("Bienvenue")

        provider = db.get_provider_from_email('*****@*****.**')
        self.assertEqual(provider.vanity_url, 'firstlast2')
示例#19
0
    def post(self, vanity_url=None, operation=None, provider_key=None):
        provider = db.get_provider_from_vanity_url(vanity_url)

        if operation == 'invite':
            form = ProviderInviteForm().get_form(self.request.POST)
            if form.validate():
                invite = Invite()
                form.populate_obj(invite)

                # check if the target email is an existing user
                target_provider = db.get_provider_from_email(invite.email)
                if target_provider:
                    # already a member, just make a connection request
                    self.redirect('/%s/connect' % target_provider.vanity_url)

                else:
                    # new person
                    # associate provider to invite
                    invite.provider = provider.key

                    # create a token for this invite that will be used to pre-populate the signup form
                    invite.token = self.create_token_oldstyle(invite.email)

                    # save
                    invite.put()

                    # create an invite url
                    url_obj = urlparse.urlparse(self.request.url)
                    invite_url = urlparse.urlunparse(
                        (url_obj.scheme, url_obj.netloc,
                         '/invite/' + invite.token, '', '', ''))
                    logging.info(
                        '(ProviderNetworkHandler.post) unique invite URL:' +
                        invite_url)

                    # send the actual email...
                    mail.email_invite(self.jinja2, invite, invite_url)

                    # all good
                    msg = _("Invitation sent to")
                    message = msg + " %s %s" % (invite.first_name,
                                                invite.last_name)

                    # new form for next invite
                    provider_invite_form = ProviderInviteForm().get_form()
                    self.render_template(
                        "provider/network.html",
                        success_message=message,
                        provider=provider,
                        provider_invite_form=provider_invite_form)
            else:
                self.render_template("provider/network.html",
                                     provider=provider,
                                     provider_invite_form=form)
        else:
            # post unknown operation

            provider_invite_form = ProviderInviteForm().get_form()
            self.render_template("provider/network.html",
                                 success_message=message,
                                 provider=provider,
                                 provider_invite_form=provider_invite_form)