Пример #1
0
 def test_provider_query(self):
     p = GoogleUserProfile()
     qry = GoogleUserProfile.query().fetch()
     self.assertEqual(len(qry), 0)
     p.put()
     # query UserProfile
     qry = UserProfile.query().fetch()
     self.assertEqual(len(qry), 1)
     qry = GoogleUserProfile.query().fetch()
     self.assertEqual(len(qry), 1)
Пример #2
0
 def test_handle_request(self):
     # No User or Profile
     p_count0 = UserProfile.query().count()
     u_count0 = User.query().count()
     self.assertEqual(p_count0, 0)
     self.assertEqual(u_count0, 0)
     # Create New User
     provider = 'gmail.com'
     req = Request.blank('/auth/appengine_openid?provider=' + provider)
     resp = req.get_response(application)
     self.assertEqual(resp.location, 'https://www.google.com/accounts/'
                                     'Login?continue=http%3A//localhost/'
                                     'auth/appengine_openid/callback')
Пример #3
0
 def post(self):
     email = self.request.POST.get('email')
     if not email:
         self.request.add_message(
             'Please enter a valid email address', 'error')
         return self.get()
     existing_account = UserProfile.get_key('password', email).get()
     if not existing_account:
         self.request.add_message(
             'The email address you provided was not found. '
             'Please try again.', 'error')
         return self.get()
     return self.sent(email)
Пример #4
0
 def post(self):
     email = self.request.POST.get('email')
     if not email or "@" not in email or "." not in email:
         self.request.add_message(
             'Please enter a valid email address', 'error')
         return self.get()
     existing_account = UserProfile.get_key('password', email).get()
     if not existing_account:
         self.request.add_message(
             'The email address you provided was not found. '
             'Please try again.', 'error')
         return self.get()
     user = User.get_by_auth_id(existing_account.key.id())
     taskqueue.add(url='/account/tasks/password-recovery-email', params={
         'recipient_id': user.key.id(),
         })
     return self.sent(email)
Пример #5
0
 def test_method_call_on_subclass(self):
     p = GoogleUserProfile()
     p.put()
     pq = UserProfile.query().get()
     v = pq.test_method_call()
     self.assertEqual(v, 'it worked.')