本文整理汇总了Python中application.models.User.update方法的典型用法代码示例。如果您正苦于以下问题:Python User.update方法的具体用法?Python User.update怎么用?Python User.update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类application.models.User
的用法示例。
在下文中一共展示了User.update方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setUp
# 需要导入模块: from application.models import User [as 别名]
# 或者: from application.models.User import update [as 别名]
def setUp(self):
self.app = application.app
bcrypt = Bcrypt(self.app)
# forcibly reconnect to testing db
connection.disconnect()
self.app.config['MONGO_CONFIG']['db_name'] = 'pipeline_testing'
self.connection = connect(
self.app.config['MONGO_CONFIG']['db_name']
, host=self.app.config['MONGO_CONFIG']['host']
, port=int(self.app.config['MONGO_CONFIG']['port'])
)
# drop any lingering test dbs
self.connection.drop_database(
self.app.config['MONGO_CONFIG']['db_name'])
member_user = User(
admin_rights = False
, email = '[email protected]'
, email_confirmation_code = 'goodday'
, email_confirmed = True
, last_login_time = datetime.datetime.utcnow()
, password_hash = bcrypt.generate_password_hash('hola!')
, registration_time = datetime.datetime.utcnow()
, verified = True)
member_user.save()
''' create a test org
'''
test_org = Organization(
label = 'best-org'
, name = 'best org')
test_org.save()
# save membership
member_user.update(push__organizations = test_org)
''' create a test project
'''
test_project = Project(
creation_time = datetime.datetime.utcnow()
, label = 'best-project'
, name = 'best project'
, organization = test_org)
test_project.save()
test_org.update(push__projects=test_project)
''' create a data-less upload
'''
'''
示例2: setUp
# 需要导入模块: from application.models import User [as 别名]
# 或者: from application.models.User import update [as 别名]
def setUp(self):
self.app = application.app
bcrypt = Bcrypt(self.app)
# forcibly reconnect to testing db
connection.disconnect()
self.app.config['MONGO_CONFIG']['db_name'] = 'pipeline_testing'
mongo_config = self.app.config['MONGO_CONFIG']
mongodb_uri = 'mongodb://'
if mongo_config['dbuser'] and mongo_config['dbpassword']:
mongodb_uri += '%s:%[email protected]' % (mongo_config['dbuser']
, mongo_config['dbpassword'])
mongodb_uri += '%s/%s' % (mongo_config['hosts'], mongo_config['db_name'])
self.connection = connect(mongo_config['db_name'], host=mongodb_uri)
# drop any lingering test dbs
self.connection.drop_database(
self.app.config['MONGO_CONFIG']['db_name'])
''' create test user
'''
member_user = User(
admin_rights = False
, email = '[email protected]'
, email_confirmation_code = 'goodday'
, email_confirmed = True
, last_login_time = datetime.utcnow()
, password_hash = bcrypt.generate_password_hash('hola!')
, registration_time = datetime.utcnow()
, verified = True)
member_user.save()
''' create test org
'''
test_org = Organization(
label = 'euro-water'
, name = 'Euro Water')
test_org.save()
# save membership
member_user.update(push__organizations = test_org)
''' create test headers
'''
date_header = Header(data_type = 'datetime', name = 'date',
label = 'date')
date_header.save()
pH_header = Header(data_type = 'number', name = 'pH', label = 'pH')
pH_header.save()
city_header = Header(data_type = 'string', name = 'city',
label = 'city')
city_header.save()
headers = [date_header, pH_header, city_header]
# save ref to this header for later test
self.date_header_id = date_header.id
''' create test project
'''
test_project = Project(
creation_time = datetime.utcnow()
, label = 'water-quality'
, name = 'water quality'
, ordered_schema = headers
, organization = test_org)
test_project.save()
test_org.update(push__projects=test_project)
''' update the headers with a ref to the project
'''
for header in headers:
header.update(set__project = test_project)
''' create test datapoints
'''
test_data = [
{'date': datetime(2012, 3, 4), 'pH': 2.2, 'city': 'Madrid'}
, {'date': datetime(2012, 3, 5), 'pH': 3, 'city': 'Paris'}
, {'date': datetime(2012, 3, 6), 'pH': 4, 'city': 'London'}
, {'date': datetime(2012, 3, 6), 'pH': 3, 'city': 'London'}
, {'date': datetime(2012, 3, 6), 'pH': None, 'city': 'London'}
]
for datapoint in test_data:
new_entry = Entry(
project = test_project
, unique = True
, values = datapoint)
new_entry.save()
示例3: setUp
# 需要导入模块: from application.models import User [as 别名]
# 或者: from application.models.User import update [as 别名]
def setUp(self):
self.app = application.app
bcrypt = Bcrypt(self.app)
# forcibly reconnect to testing db
connection.disconnect()
self.app.config['MONGO_CONFIG']['db_name'] = 'pipeline_testing'
mongo_config = self.app.config['MONGO_CONFIG']
mongodb_uri = 'mongodb://'
if mongo_config['dbuser'] and mongo_config['dbpassword']:
mongodb_uri += '%s:%[email protected]' % (mongo_config['dbuser']
, mongo_config['dbpassword'])
mongodb_uri += '%s/%s' % (mongo_config['hosts'], mongo_config['db_name'])
self.connection = connect(mongo_config['db_name'], host=mongodb_uri)
# drop any lingering test dbs
self.connection.drop_database(
self.app.config['MONGO_CONFIG']['db_name'])
admin_user = User(
admin_rights = True
, email = '[email protected]'
, email_confirmation_code = 'goodday'
, email_confirmed = True
, last_login_time = datetime.datetime.utcnow()
, password_hash = bcrypt.generate_password_hash('hola!')
, registration_time = datetime.datetime.utcnow()
, verified = True)
admin_user.save()
# same as verified but will push into an org for membership
member_user = User(
admin_rights = False
, email = '[email protected]'
, email_confirmation_code = 'goodday'
, email_confirmed = True
, last_login_time = datetime.datetime.utcnow()
, password_hash = bcrypt.generate_password_hash('hola!')
, registration_time = datetime.datetime.utcnow()
, verified = True)
member_user.save()
verified_user = User(
admin_rights = False
, email = '[email protected]'
, email_confirmation_code = 'goodday'
, email_confirmed = True
, last_login_time = datetime.datetime.utcnow()
, password_hash = bcrypt.generate_password_hash('hola!')
, registration_time = datetime.datetime.utcnow()
, verified = True)
verified_user.save()
unverified_user = User(
admin_rights = False
, email = '[email protected]'
, email_confirmation_code = 'goodday'
, email_confirmed = True
, last_login_time = datetime.datetime.utcnow()
, password_hash = bcrypt.generate_password_hash('hola!')
, registration_time = datetime.datetime.utcnow()
, verified = False)
unverified_user.save()
''' create a test org
'''
test_org = Organization(
label = 'best-org'
, name = 'best org')
test_org.save()
# save membership
member_user.update(push__organizations = test_org)
''' create a test project
'''
test_project = Project(
creation_time = datetime.datetime.utcnow()
, label = 'best-project'
, name = 'best project'
, organization = test_org)
test_project.save()
test_org.update(push__projects=test_project)