本文整理汇总了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)
示例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))