Пример #1
0
  def test_cron_only_admin(self):
    from kay.auth.models import DatastoreUser
    user = DatastoreUser(
        key_name=DatastoreUser.get_key_name("foobar"),
        user_name="foobar",
        password=DatastoreUser.hash_password("password")
    )
    user.is_admin = True
    user.put()

    self.client.test_login(username='******')
    response = self.client.get('/cron')
    self.assertEqual(response.status_code, 200)
    self.assertTrue(response.data == "OK")
Пример #2
0
def _create_fb_user(fb_uid):
    from kay.auth.models import DatastoreUser
    user = DatastoreUser(email = '*****@*****.**' % fb_uid, 
                         user_name = 'facebook_user_%s' % fb_uid,
                         password = '******',
                         key_name = 'u:' + str(fb_uid))
    user.put()
    #facebook_data = get_facebook_data_for_uid(fb_uid)
    # TODO: Use OAuth2 to retrieve userprofile values from fb
    userprofile = UserProfile(location = '',
                              bio = '',
                              website = '',
                              user = user)
    userprofile.put()
    facebook_profile = FacebookProfile(fb_uid = fb_uid, userprofile = userprofile) 
    facebook_profile.put()
    return user