def testRunBackgroundTasksForDay(self): self.testUsers = [ "*****@*****.**", "*****@*****.**", "*****@*****.**", "*****@*****.**", "*****@*****.**" ] 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())
def setUp(self): self.testUsers = [ "*****@*****.**", "*****@*****.**", "*****@*****.**", "*****@*****.**", "*****@*****.**" ] 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(edb._get_current_db()) self.Profiles = get_profile_db() self.assertEquals(self.Profiles.estimated_document_count(), 0) emission.tests.common.loadTable(self.serverName, "Stage_Profiles", "emission/tests/data/profiles.json") self.assertEquals(self.Profiles.estimated_document_count(), 1) # 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 = old_div(267.0, 1609) self.now = datetime.now() self.dayago = self.now - timedelta(days=1) self.weekago = self.now - timedelta(weeks=1)
def setUp(self): self.testUsers = [ "*****@*****.**", "*****@*****.**", "*****@*****.**", "*****@*****.**", "*****@*****.**" ] 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)
def setUp(self): self.testUsers = ["*****@*****.**", "*****@*****.**", "*****@*****.**", "*****@*****.**", "*****@*****.**"] 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)
def setUp(self): self.testUsers = [ "*****@*****.**", "*****@*****.**", "*****@*****.**", "*****@*****.**", "*****@*****.**" ] 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()
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("*****@*****.**") self.uuid = user.uuid
def setupClientTest(self): # At this point, the more important test is to execute the query and see # how well it works fakeEmail = "*****@*****.**" 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("*****@*****.**") 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)
def setUp(self): self.testUsers = [ "*****@*****.**", "*****@*****.**", "*****@*****.**", "*****@*****.**", "*****@*****.**" ] self.serverName = edb.url self.ModesColl = get_mode_db() self.SectionsColl = get_section_db() # Let's make sure that the users are registered so that they have profiles user_objects = [] for userEmail in self.testUsers: user_objects.append(User.register(userEmail)) # 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 for testUser in user_objects: etc.purgeSectionData(self.SectionsColl, testUser.uuid) if self.ModesColl.estimated_document_count() > 0: self.ModesColl.delete_many({}) self.assertEqual(self.ModesColl.estimated_document_count(), 0) self.assertEqual(self.SectionsColl.estimated_document_count(), 0) MongoClient(edb.url).drop_database("Backup_database") etc.loadTable(self.serverName, "Stage_Modes", "emission/tests/data/modes.json") etc.loadTable(self.serverName, "Stage_Sections", "emission/tests/data/testModeInferSeedFile") 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 edb.save(self.SectionsColl, section) self.pipeline = pipeline.ModeInferencePipelineMovesFormat() self.testLoadTrainingData()
def testChangeUpdateTs(self): from datetime import datetime, timedelta user = User.register('*****@*****.**') self.assertTrue(User.isRegistered('*****@*****.**')) user.changeUpdateTs(timedelta(days = -20)) self.assertEqual((datetime.now() - user.getUpdateTS()).days, 20)
def testClientSpecificSettersWithOverride(self): fakeEmail = "*****@*****.**" 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("*****@*****.**") 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)
def setupClientTest(self): # At this point, the more important test is to execute the query and see # how well it works fakeEmail = "*****@*****.**" 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("*****@*****.**") 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)
def testUnsetStudyExists(self): user = User.register('*****@*****.**') user.setStudy('testclient') self.assertEquals(userclient.countForStudy('testclient'), 1) user.unsetStudy('testclient') self.assertEquals(userclient.countForStudy('testclient'), 0)
def setUp(self): self.testUsers = [ "*****@*****.**", "*****@*****.**", "*****@*****.**", "*****@*****.**", "*****@*****.**", ] 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()
def testRegisterExistingUser(self): user = User.register('*****@*****.**') self.assertEquals(user.getStudy(), []) client = Client("testclient") client.update(createKey = False) common.makeValid(client) (resultPre, resultReg) = client.preRegister("this_is_the_super_secret_id", "*****@*****.**") self.assertEqual(resultPre, 0) self.assertEqual(resultReg, 1) user = User.fromEmail("*****@*****.**") self.assertEquals(user.getStudy(), ['testclient']) # Here's the key difference, now register again user = User.register('*****@*****.**') self.assertEquals(user.getStudy(), ['testclient'])
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("*****@*****.**") 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)
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("*****@*****.**") 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)
def testGetSettingsCustomUser(self): client = Client("testclient") client.update(createKey = False) common.makeValid(client) (resultPre, resultReg) = client.preRegister("this_is_the_super_secret_id", "*****@*****.**") self.assertEqual(resultPre, 1) self.assertEqual(resultReg, 0) user = User.register('*****@*****.**') self.assertRegexpMatches(user.getSettings()['result_url'], ".*/test/test/test")
def testRegisterStudyUser(self): client = Client("testclient") client.update(createKey = False) common.makeValid(client) (resultPre, resultReg) = client.preRegister("this_is_the_super_secret_id", "*****@*****.**") self.assertEqual(resultPre, 1) self.assertEqual(resultReg, 0) user = User.register('*****@*****.**') self.assertEquals(user.getStudy(), ['testclient'])
def testCountForStudy(self): client = Client("testclient") client.update(createKey = False) common.makeValid(client) (resultPre, resultReg) = client.preRegister("this_is_the_super_secret_id", "*****@*****.**") self.assertEqual(resultPre, 1) self.assertEqual(resultReg, 0) user = User.register('*****@*****.**') self.assertEquals(userclient.countForStudy('testclient'), 1)
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)
def testRunBackgroundTasksForDay(self): self.testUsers = ["*****@*****.**", "*****@*****.**", "*****@*****.**", "*****@*****.**", "*****@*****.**"] 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())
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()
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();
def testPreRegisterExistingUser(self): user = User.register("*****@*****.**") client = Client("testclient") client.update(createKey = False) common.makeValid(client) (resultPre, resultReg) = client.preRegister("this_is_the_super_secret_id", "*****@*****.**") self.assertEqual(resultPre, 0) self.assertEqual(resultReg, 1) self.assertEqual(user.getStudy(), ['testclient']) pendingRegs = Client.getPendingClientRegs("*****@*****.**") self.assertEqual(pendingRegs, [])
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)}
def testGetFirstStudy(self): user = User.register('*****@*****.**') self.assertTrue(User.isRegistered('*****@*****.**')) client = Client("testclient") client.update(createKey = False) common.makeValid(client) (resultPre, resultReg) = client.preRegister("this_is_the_super_secret_id", "*****@*****.**") self.assertEqual(resultPre, 0) self.assertEqual(resultReg, 1) user = User.fromEmail('*****@*****.**') self.assertEqual(user.getFirstStudy(), 'testclient')
def testSetClientSpecificFields(self): user = User.register('*****@*****.**') self.assertTrue(User.isRegistered('*****@*****.**')) # 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'})
def testClientSpecificSettersNoOverride(self): fakeEmail = "*****@*****.**" user = User.register("*****@*****.**") self.assertEqual(user.getFirstStudy(), None) 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(user.getFirstStudy()).clientSpecificSetters(user.uuid, dummySection, dummyPredModeMap) self.assertEqual(clientSetQuery, None)
def setupUserAndClient(self): # At this point, the more important test is to execute the query and see # how well it works fakeEmail = "*****@*****.**" client = Client("gamified") client.update(createKey = False) etc.makeValid(client) (resultPre, resultReg) = client.preRegister("this_is_the_super_secret_id", fakeEmail) studyList = Client.getPendingClientRegs(fakeEmail) self.assertEqual(studyList, ["gamified"]) user = User.register("*****@*****.**") self.assertEqual(user.getFirstStudy(), 'gamified') self.user = user
def testGetCarbonFootprintForMode(self): user = User.register('*****@*****.**') user.setMpgArray([45, 50, 31]) # Avg MPG = 42 correctCarbonFootprintForMode = {'walking' : 0, 'running' : 0, 'cycling' : 0, 'mixed' : 0, 'bus_short' : old_div(267.0,1609), 'bus_long' : old_div(267.0,1609), 'train_short' : old_div(92.0,1609), 'train_long' : old_div(92.0,1609), 'car_short' : (old_div(1,(42*1.6093)))*8.91, 'car_long' : (old_div(1,(42*1.6093)))*8.91, 'air_short' : old_div(217.0,1609), 'air_long' : old_div(217.0,1609) } self.assertEqual(user.getCarbonFootprintForMode(), correctCarbonFootprintForMode)
def testGetSectionFilter(self): fakeEmail = "*****@*****.**" 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("*****@*****.**") self.assertEqual(user.getFirstStudy(), 'testclient') self.assertEqual(client.getSectionFilter(user.uuid), []) # Now, set the update timestamp to two weeks ago common.updateUserCreateTime(user.uuid) self.assertEqual(client.getSectionFilter(user.uuid), [{'test_auto_confirmed.prob': {'$lt': 0.9}}])
def testGetCarbonFootprintForMode(self): user = User.register('*****@*****.**') 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)
def setupUserAndClient(self): # At this point, the more important test is to execute the query and see # how well it works fakeEmail = "*****@*****.**" client = Client("gamified") 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, ["gamified"]) user = User.register("*****@*****.**") self.assertEqual(user.getFirstStudy(), 'gamified') self.user = user
def testGetAvgMpg(self): user = User.register('*****@*****.**') user.setMpgArray([45, 50, 31]) self.assertEqual(user.getAvgMpg(), 42)
def testRegisterUser(self): user = User.register('*****@*****.**') self.assertTrue(User.isRegistered('*****@*****.**'))
def testGetSettingsDefaultUser(self): user = User.register('*****@*****.**') self.assertRegexpMatches(user.getSettings()['result_url'], ".*/compare")
def testUnregister(self): user = User.register('*****@*****.**') self.assertTrue(User.isRegistered('*****@*****.**')) User.unregister('*****@*****.**') self.assertFalse(User.isRegistered('*****@*****.**'))
def testIsRegistered(self): user = User.register('*****@*****.**') self.assertTrue(User.isRegistered('*****@*****.**'))
def testGetAvgMpg(self): user = User.register('*****@*****.**') user.setMpgArray([45, 50, 31]) self.assertEquals(user.getAvgMpg(), 42)
def testCountForStudyDefault(self): user = User.register('*****@*****.**') self.assertEquals(userclient.countForStudy('testclient'), 0) self.assertEquals(userclient.countForStudy(None), 1)
def testGetSettingsDefaultUser(self): user = User.register('*****@*****.**') self.assertRegex(user.getSettings()['result_url'], ".*/compare")
def testRegisterExistingUser(self): user = User.register('*****@*****.**') # Here's the key difference, now register again user = User.register('*****@*****.**') self.assertTrue(User.isRegistered("*****@*****.**"))
def testRegisterNonStudyUser(self): user = User.register('*****@*****.**') self.assertEquals(user.getStudy(), [])