本文整理汇总了Python中dao.user.User.register方法的典型用法代码示例。如果您正苦于以下问题:Python User.register方法的具体用法?Python User.register怎么用?Python User.register使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dao.user.User
的用法示例。
在下文中一共展示了User.register方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setUp
# 需要导入模块: from dao.user import User [as 别名]
# 或者: from dao.user.User import register [as 别名]
def setUp(self):
self.testUsers = ["[email protected]", "[email protected]", "[email protected]",
"[email protected]", "[email protected]"]
self.serverName = 'localhost'
# Sometimes, we may have entries left behind in the database if one of the tests failed
# or threw an exception, so let us start by cleaning up all entries
tests.common.dropAllCollections(get_db())
self.ModesColl = get_mode_db()
# self.ModesColl.remove()
self.assertEquals(self.ModesColl.find().count(), 0)
self.SectionsColl = get_section_db()
# self.SectionsColl.remove()
self.assertEquals(self.SectionsColl.find().count(), 0)
load_database_json.loadTable(self.serverName, "Stage_Modes", "tests/data/modes.json")
load_database_json.loadTable(self.serverName, "Stage_Sections", "tests/data/testCarbonFile")
# Let's make sure that the users are registered so that they have profiles
for userEmail in self.testUsers:
User.register(userEmail)
self.walkExpect = 1057.2524056424411
self.busExpect = 2162.668467546699
self.busCarbon = 267.0/1609
self.now = datetime.now()
self.dayago = self.now - timedelta(days=1)
self.weekago = self.now - timedelta(weeks = 1)
tests.common.updateSections(self)
示例2: testChangeUpdateTs
# 需要导入模块: from dao.user import User [as 别名]
# 或者: from dao.user.User import register [as 别名]
def testChangeUpdateTs(self):
from datetime import datetime, timedelta
user = User.register('[email protected]')
self.assertTrue(User.isRegistered('[email protected]'))
user.changeUpdateTs(timedelta(days = -20))
self.assertEqual((datetime.now() - user.getUpdateTS()).days, 20)
示例3: testUnsetStudyExists
# 需要导入模块: from dao.user import User [as 别名]
# 或者: from dao.user.User import register [as 别名]
def testUnsetStudyExists(self):
user = User.register('[email protected]')
user.setStudy('testclient')
self.assertEquals(userclient.countForStudy('testclient'), 1)
user.unsetStudy('testclient')
self.assertEquals(userclient.countForStudy('testclient'), 0)
示例4: testRegisterExistingUser
# 需要导入模块: from dao.user import User [as 别名]
# 或者: from dao.user.User import register [as 别名]
def testRegisterExistingUser(self):
user = User.register('[email protected]')
self.assertEquals(user.getStudy(), [])
client = Client("testclient")
client.update(createKey = False)
common.makeValid(client)
(resultPre, resultReg) = client.preRegister("this_is_the_super_secret_id", "[email protected]")
self.assertEqual(resultPre, 0)
self.assertEqual(resultReg, 1)
user = User.fromEmail("[email protected]")
self.assertEquals(user.getStudy(), ['testclient'])
# Here's the key difference, now register again
user = User.register('[email protected]')
self.assertEquals(user.getStudy(), ['testclient'])
示例5: testGetSettingsCustomUser
# 需要导入模块: from dao.user import User [as 别名]
# 或者: from dao.user.User import register [as 别名]
def testGetSettingsCustomUser(self):
client = Client("testclient")
client.update(createKey = False)
common.makeValid(client)
(resultPre, resultReg) = client.preRegister("this_is_the_super_secret_id", "[email protected]")
self.assertEqual(resultPre, 1)
self.assertEqual(resultReg, 0)
user = User.register('[email protected]')
self.assertRegexpMatches(user.getSettings()['result_url'], ".*/test/test/test")
示例6: testRegisterStudyUser
# 需要导入模块: from dao.user import User [as 别名]
# 或者: from dao.user.User import register [as 别名]
def testRegisterStudyUser(self):
client = Client("testclient")
client.update(createKey = False)
common.makeValid(client)
(resultPre, resultReg) = client.preRegister("this_is_the_super_secret_id", "[email protected]")
self.assertEqual(resultPre, 1)
self.assertEqual(resultReg, 0)
user = User.register('[email protected]')
self.assertEquals(user.getStudy(), ['testclient'])
示例7: testRunBackgroundTasksForDay
# 需要导入模块: from dao.user import User [as 别名]
# 或者: from dao.user.User import register [as 别名]
def testRunBackgroundTasksForDay(self):
self.testUsers = ["[email protected]", "[email protected]", "[email protected]",
"[email protected]", "[email protected]"]
load_database_json.loadTable(self.serverName, "Stage_Modes", "tests/data/modes.json")
load_database_json.loadTable(self.serverName, "Stage_Sections", "tests/data/testCarbonFile")
# Let's make sure that the users are registered so that they have profiles
for userEmail in self.testUsers:
User.register(userEmail)
self.SectionsColl = get_section_db()
tests.common.updateSections(self)
self.assertNotEqual(len(self.uuid_list), 0)
# Can access the zeroth element because we know that then length is greater than zero
# (see above)
test_uuid = self.uuid_list[0]
test_user = User.fromUUID(test_uuid)
self.assertNotIn('carbon_footprint', test_user.getProfile().keys())
data.runBackgroundTasks(test_user.uuid)
self.assertIn('carbon_footprint', test_user.getProfile().keys())
示例8: setUp
# 需要导入模块: from dao.user import User [as 别名]
# 或者: from dao.user.User import register [as 别名]
def setUp(self):
self.testUsers = ["[email protected]", "[email protected]", "[email protected]",
"[email protected]", "[email protected]"]
self.serverName = 'localhost'
# Sometimes, we may have entries left behind in the database if one of the tests failed
# or threw an exception, so let us start by cleaning up all entries
tests.common.dropAllCollections(get_db())
self.ModesColl = get_mode_db()
self.assertEquals(self.ModesColl.find().count(), 0)
self.SectionsColl = get_section_db()
self.assertEquals(self.SectionsColl.find().count(), 0)
load_database_json.loadTable(self.serverName, "Stage_Modes", "tests/data/modes.json")
load_database_json.loadTable(self.serverName, "Stage_Sections", "tests/data/testModeInferFile")
# Let's make sure that the users are registered so that they have profiles
for userEmail in self.testUsers:
User.register(userEmail)
self.now = datetime.now()
self.dayago = self.now - timedelta(days=1)
self.weekago = self.now - timedelta(weeks = 1)
for section in self.SectionsColl.find():
section['section_start_datetime'] = self.dayago
section['section_end_datetime'] = self.dayago + timedelta(hours = 1)
if (section['confirmed_mode'] == 5):
# We only cluster bus and train trips
# And our test data only has bus trips
section['section_start_point'] = {u'type': u'Point', u'coordinates': [-122.270039042, 37.8800285728]}
section['section_end_point'] = {u'type': u'Point', u'coordinates': [-122.2690412952, 37.8739578595]}
# print("Section start = %s, section end = %s" %
# (section['section_start_datetime'], section['section_end_datetime']))
# Replace the user email with the UUID
section['user_id'] = User.fromEmail(section['user_id']).uuid
self.SectionsColl.save(section)
self.pr = precompute_results.PrecomputeResults()
示例9: testSetClientSpecificFields
# 需要导入模块: from dao.user import User [as 别名]
# 或者: from dao.user.User import register [as 别名]
def testSetClientSpecificFields(self):
user = User.register('[email protected]')
self.assertTrue(User.isRegistered('[email protected]'))
# Check that the field doesn't exist initially
self.assertTrue(user.getProfile().get('test_field', 'blank'), 'blank')
# Check that a simple value update works
user.setClientSpecificProfileFields({'test_field': 'something beautiful'})
self.assertTrue(user.getProfile().get('test_field', 'blank'), 'something beautiful')
# Check that a data structure update works
user.setClientSpecificProfileFields({'test_field': {'something': 'beautiful'}})
self.assertTrue(user.getProfile().get('test_field', 'blank'), {'something': 'beautiful'})
示例10: createUserProfile
# 需要导入模块: from dao.user import User [as 别名]
# 或者: from dao.user.User import register [as 别名]
def createUserProfile():
logging.debug("Called createUserProfile")
userToken = request.json['user']
# This is the only place we should use the email, since we may not have a
# UUID yet. All others should only use the UUID.
if skipAuth:
userEmail = userToken
else:
userEmail = verifyUserToken(userToken)
logging.debug("userEmail = %s" % userEmail)
user = User.register(userEmail)
logging.debug("Looked up user = %s" % user)
logging.debug("Returning result %s" % {'uuid': str(user.uuid)})
return {'uuid': str(user.uuid)}
示例11: testGetFirstStudy
# 需要导入模块: from dao.user import User [as 别名]
# 或者: from dao.user.User import register [as 别名]
def testGetFirstStudy(self):
user = User.register('[email protected]')
self.assertTrue(User.isRegistered('[email protected]'))
client = Client("testclient")
client.update(createKey = False)
common.makeValid(client)
(resultPre, resultReg) = client.preRegister("this_is_the_super_secret_id", "[email protected]")
self.assertEqual(resultPre, 0)
self.assertEqual(resultReg, 1)
user = User.fromEmail('[email protected]')
self.assertEqual(user.getFirstStudy(), 'testclient')
示例12: testGetCarbonFootprintForMode
# 需要导入模块: from dao.user import User [as 别名]
# 或者: from dao.user.User import register [as 别名]
def testGetCarbonFootprintForMode(self):
user = User.register('[email protected]')
user.setMpgArray([45, 50, 31])
# Avg MPG = 42
correctCarbonFootprintForMode = {'walking' : 0,
'running' : 0,
'cycling' : 0,
'mixed' : 0,
'bus_short' : 267.0/1609,
'bus_long' : 267.0/1609,
'train_short' : 92.0/1609,
'train_long' : 92.0/1609,
'car_short' : (1/(42*1.6093))*8.91,
'car_long' : (1/(42*1.6093))*8.91,
'air_short' : 217.0/1609,
'air_long' : 217.0/1609
}
self.assertEquals(user.getCarbonFootprintForMode(), correctCarbonFootprintForMode)
示例13: setupUserAndClient
# 需要导入模块: from dao.user import User [as 别名]
# 或者: from dao.user.User import register [as 别名]
def setupUserAndClient(self):
# At this point, the more important test is to execute the query and see
# how well it works
from dao.user import User
from dao.client import Client
import tests.common
from datetime import datetime, timedelta
from get_database import get_section_db
fakeEmail = "[email protected]"
client = Client("gamified")
client.update(createKey = False)
tests.common.makeValid(client)
(resultPre, resultReg) = client.preRegister("this_is_the_super_secret_id", fakeEmail)
studyList = Client.getPendingClientRegs(fakeEmail)
self.assertEqual(studyList, ["gamified"])
user = User.register("[email protected]")
self.assertEqual(user.getFirstStudy(), 'gamified')
self.user = user
示例14: testCountForStudyDefault
# 需要导入模块: from dao.user import User [as 别名]
# 或者: from dao.user.User import register [as 别名]
def testCountForStudyDefault(self):
from get_database import get_profile_db, get_uuid_db, get_client_db, get_pending_signup_db
user = User.register('[email protected]')
self.assertEquals(userclient.countForStudy('testclient'), 0)
self.assertEquals(userclient.countForStudy(None), 1)
示例15: testGetSettingsDefaultUser
# 需要导入模块: from dao.user import User [as 别名]
# 或者: from dao.user.User import register [as 别名]
def testGetSettingsDefaultUser(self):
user = User.register('[email protected]')
self.assertRegexpMatches(user.getSettings()['result_url'], ".*/compare")