本文整理汇总了Python中emission.core.wrapper.user.User.register方法的典型用法代码示例。如果您正苦于以下问题:Python User.register方法的具体用法?Python User.register怎么用?Python User.register使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类emission.core.wrapper.user.User
的用法示例。
在下文中一共展示了User.register方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setUp
# 需要导入模块: from emission.core.wrapper.user import User [as 别名]
# 或者: from emission.core.wrapper.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
emission.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)
emission.tests.common.loadTable(self.serverName, "Stage_Modes", "emission/tests/data/modes.json")
emission.tests.common.loadTable(self.serverName, "Stage_Sections", "emission/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)
emission.tests.common.updateSections(self)
示例2: testUnsetStudyExists
# 需要导入模块: from emission.core.wrapper.user import User [as 别名]
# 或者: from emission.core.wrapper.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)
示例3: setupClientTest
# 需要导入模块: from emission.core.wrapper.user import User [as 别名]
# 或者: from emission.core.wrapper.user.User import register [as 别名]
def setupClientTest(self):
# At this point, the more important test is to execute the query and see
# how well it works
fakeEmail = "[email protected]"
client = Client("testclient")
client.update(createKey = False)
emission.tests.common.makeValid(client)
(resultPre, resultReg) = client.preRegister("this_is_the_super_secret_id", fakeEmail)
studyList = Client.getPendingClientRegs(fakeEmail)
self.assertEqual(studyList, ["testclient"])
user = User.register("[email protected]")
self.assertEqual(user.getFirstStudy(), 'testclient')
dummyPredModeMap = {'walking': 1.0}
dummySection = emission.tests.common.createDummySection(
startTime = datetime.now() - timedelta(seconds = 60 * 60),
endTime = datetime.now(),
startLoc = [-122, 34],
endLoc = [-122, 35],
predictedMode = dummyPredModeMap)
return (user, dummySection, dummyPredModeMap)
示例4: testClientSpecificSettersWithOverride
# 需要导入模块: from emission.core.wrapper.user import User [as 别名]
# 或者: from emission.core.wrapper.user.User import register [as 别名]
def testClientSpecificSettersWithOverride(self):
fakeEmail = "[email protected]"
client = Client("testclient")
client.update(createKey = False)
common.makeValid(client)
(resultPre, resultReg) = client.preRegister("this_is_the_super_secret_id", fakeEmail)
studyList = Client.getPendingClientRegs(fakeEmail)
self.assertEqual(studyList, ["testclient"])
user = User.register("[email protected]")
self.assertEqual(user.getFirstStudy(), 'testclient')
dummyPredModeMap = {'walking': 1.0}
dummySection = common.createDummySection(startTime = datetime.now() - timedelta(seconds = 60 * 60),
endTime = datetime.now(),
startLoc = [-122, 34],
endLoc = [-122, 35],
predictedMode = dummyPredModeMap)
clientSetQuery = client.clientSpecificSetters(user.uuid, dummySection['_id'], dummyPredModeMap)
self.assertEqual(clientSetQuery, {'$set': {'test_auto_confirmed': {'mode': 1, 'prob': 1.0}}})
# Apply the change
get_section_db().update({'_id': dummySection['_id']}, clientSetQuery)
retrievedSection = get_section_db().find_one({'_id': dummySection['_id']})
self.assertEqual(retrievedSection['test_auto_confirmed']['mode'], 1)
示例5: testChangeUpdateTs
# 需要导入模块: from emission.core.wrapper.user import User [as 别名]
# 或者: from emission.core.wrapper.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)
示例6: setUp
# 需要导入模块: from emission.core.wrapper.user import User [as 别名]
# 或者: from emission.core.wrapper.user.User import register [as 别名]
def setUp(self):
import emission.tests.common
# 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
emission.tests.common.dropAllCollections(get_db())
user = User.register("[email protected]")
self.uuid = user.uuid
示例7: setUp
# 需要导入模块: from emission.core.wrapper.user import User [as 别名]
# 或者: from emission.core.wrapper.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
emission.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)
emission.tests.common.loadTable(self.serverName, "Stage_Modes", "emission/tests/data/modes.json")
emission.tests.common.loadTable(self.serverName, "Stage_Sections", "emission/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.pipeline = pipeline.ModeInferencePipeline()
self.testLoadTrainingData()
示例8: testRegisterExistingUser
# 需要导入模块: from emission.core.wrapper.user import User [as 别名]
# 或者: from emission.core.wrapper.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'])
示例9: setUp
# 需要导入模块: from emission.core.wrapper.user import User [as 别名]
# 或者: from emission.core.wrapper.user.User import register [as 别名]
def setUp(self):
# 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
emission.tests.common.dropAllCollections(get_db())
user = User.register("[email protected]")
self.uuid = user.uuid
self.serverName = "localhost"
self.now = datetime.now()
self.dayago = self.now - timedelta(days=1)
self.weekago = self.now - timedelta(weeks = 1)
示例10: testCountForStudy
# 需要导入模块: from emission.core.wrapper.user import User [as 别名]
# 或者: from emission.core.wrapper.user.User import register [as 别名]
def testCountForStudy(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(userclient.countForStudy('testclient'), 1)
示例11: testGetSettingsCustomUser
# 需要导入模块: from emission.core.wrapper.user import User [as 别名]
# 或者: from emission.core.wrapper.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")
示例12: createUserProfile
# 需要导入模块: from emission.core.wrapper.user import User [as 别名]
# 或者: from emission.core.wrapper.user.User import register [as 别名]
def createUserProfile():
try:
logging.debug("Called createUserProfile")
userEmail = enaa._getEmail(request, auth_method)
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)}
except ValueError as e:
traceback.print_exc()
abort(403, e.message)
示例13: register_user
# 需要导入模块: from emission.core.wrapper.user import User [as 别名]
# 或者: from emission.core.wrapper.user.User import register [as 别名]
def register_user(userEmail):
"""
Does some sanity checking and then registers the user with the specified email address.
This is useful for testing.
"""
if User.fromEmail(userEmail) is not None:
raise RuntimeError("User with email %s already exists" % userEmail)
userObj = User.register(userEmail)
print "Registration successful!"
print "User profile is %s" % userObj.getProfile();
示例14: testRunBackgroundTasksForDay
# 需要导入模块: from emission.core.wrapper.user import User [as 别名]
# 或者: from emission.core.wrapper.user.User import register [as 别名]
def testRunBackgroundTasksForDay(self):
self.testUsers = ["[email protected]", "[email protected]", "[email protected]",
"[email protected]", "[email protected]"]
emission.tests.common.loadTable(self.serverName, "Stage_Modes", "emission/tests/data/modes.json")
emission.tests.common.loadTable(self.serverName, "Stage_Sections", "emission/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()
emission.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())
示例15: testPreRegisterExistingUser
# 需要导入模块: from emission.core.wrapper.user import User [as 别名]
# 或者: from emission.core.wrapper.user.User import register [as 别名]
def testPreRegisterExistingUser(self):
user = User.register("[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)
self.assertEqual(user.getStudy(), ['testclient'])
pendingRegs = Client.getPendingClientRegs("[email protected]")
self.assertEqual(pendingRegs, [])