当前位置: 首页>>代码示例>>Python>>正文


Python APIDB.create_user方法代码示例

本文整理汇总了Python中api_db_utils.APIDB.create_user方法的典型用法代码示例。如果您正苦于以下问题:Python APIDB.create_user方法的具体用法?Python APIDB.create_user怎么用?Python APIDB.create_user使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在api_db_utils.APIDB的用法示例。


在下文中一共展示了APIDB.create_user方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: setUp

# 需要导入模块: from api_db_utils import APIDB [as 别名]
# 或者: from api_db_utils.APIDB import create_user [as 别名]
    def setUp(self):
        app_trainee
        app_admin
        # logging.config.fileConfig('../logging.conf')
        self.logger = logging.getLogger(__name__)

        # First, create an instance of the Testbed class.
        self.testbed = testbed.Testbed()
        # Then activate the testbed, which prepares the service stubs for use.
        self.testbed.activate()
        # Next, declare which service stubs you want to use.
        self.testbed.init_datastore_v3_stub()
        self.testbed.init_memcache_stub()
        self.testbed.init_urlfetch_stub()
        self.testbed.init_taskqueue_stub()
        self.testbed.init_search_stub()
        # check http://webtest.pythonpaste.org/en/latest/index.html for this

        self.user = APIDB.create_user("own:" + "member", nickname="member", name="test", gender="m", avatar="..",
                                      birthday=datetime.now(), country='Italy', city='TN', language='en',
                                      picture='..', email='[email protected]', phone='2313213', active_club=None,
                                      unique_properties=['email'])
        self.coach = APIDB.create_user("own:" + "trainer", nickname="trainer", name="trainer", gender="m",
                                       avatar="..",
                                       birthday=datetime.now(), country='Italy', city='TN', language='en',
                                       picture='..', email='[email protected]', phone='2313213', owner_club=None,
                                       unique_properties=['email'])
        self.owner = APIDB.create_user("own:" + "owner", nickname="owner", name="owner", gender="m", avatar="..",
                                       birthday=datetime.now(), country='Italy', city='TN', language='en',
                                       picture='..', email='[email protected]', phone='2313213', owner_club=None,
                                       unique_properties=['email'])
        # dummy user used in tests to see what others can do
        self.create_user = APIDB.create_user("own:" + "dummy", nickname="dummy", name="dummy", gender="m", avatar="..",
                                             birthday=datetime.now(), country='Italy', city='TN', language='en',
                                             picture='..', email='[email protected]', phone='2313213', active_club=None,
                                             owner_club=None, unique_properties=['email'])
        self.dummy = self.create_user
        self.auth_headers_trainee = {'Authorization': str('Token %s' % GCAuth.auth_user_token(self.user)),
                                     'X-App-Id': 'trainee'}
        # self.cookie_trainee = GCAuth.get_secure_cookie(self.token_trainee)

        self.auth_headers_coach = {'Authorization': str('Token %s' % GCAuth.auth_user_token(self.coach)),
                                   'X-App-Id': 'coach'}
        self.auth_headers_owner = {'Authorization': str('Token %s' % GCAuth.auth_user_token(self.owner)),
                                   'X-App-Id': 'coach'}

        # he can be both
        self.auth_headers_coach_dummy = {'Authorization': str('Token %s' % GCAuth.auth_user_token(self.dummy)),
                                         'X-App-Id': 'coach'}
        self.auth_headers_trainee_dummy = {'Authorization': str('Token %s' % GCAuth.auth_user_token(self.dummy)),
                                           'X-App-Id': 'trainee'}
        self.app = webtest.TestApp(app)
开发者ID:gymcentral,项目名称:gymcentral,代码行数:54,代码来源:test.py

示例2: test_user_search

# 需要导入模块: from api_db_utils import APIDB [as 别名]
# 或者: from api_db_utils.APIDB import create_user [as 别名]
    def test_user_search(self):
        APIDB.create_user("own:" + "member", username="stefano", name="test", gender="m", avatar="..",
                          birthday=datetime.now(), country='Italy', city='TN', language='en',
                          picture='..', email='[email protected]', phone='2313213', active_club=None,
                          unique_properties=['email'])
        APIDB.create_user("own:" + "trainer", username="trainer", name="trainer", gender="m",
                          avatar="..",
                          birthday=datetime.now(), country='Italy', city='TN', language='en',
                          picture='..', email='[email protected]', phone='2313213', active_club=None,
                          unique_properties=['email'])
        APIDB.create_user("own:" + "owner", username="owner", name="owner", gender="m", avatar="..",
                          birthday=datetime.now(), country='Italy', city='TN', language='en',
                          picture='..', email='[email protected]', phone='2313213', active_club=None,
                          unique_properties=['email'])
        # dummy user used in tests to see what others can do
        to_change = APIDB.create_user("own:" + "dummy", username="member dummy", name="dummy", gender="m", avatar="..",
                          birthday=datetime.now(), country='Italy', city='TN', language='en',
                          picture='..', email='[email protected]', phone='2313213', active_club=None,
                          unique_properties=['email'])

        index = search.Index(name="users")
        query_string = "stefano"
        query_options = search.QueryOptions(ids_only=True)
        query = search.Query(query_string=query_string, options=query_options)
        results = [Key(urlsafe=r.doc_id) for r in index.search(query)]
        print len(ndb.get_multi(results))
        to_change.email = "[email protected]"
        to_change.put()
        query = search.Query(query_string=query_string, options=query_options)
        results = [Key(urlsafe=r.doc_id) for r in index.search(query)]
        print len(ndb.get_multi(results))
开发者ID:gymcentral,项目名称:gymcentral,代码行数:33,代码来源:test_search.py


注:本文中的api_db_utils.APIDB.create_user方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。