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 __preRegister(self, userEmail): from dao.user import User from main import userclient if User.isRegistered(userEmail): User.fromEmail(userEmail).setStudy(self.clientName) else: pendingDoc = { 'user_email': userEmail, 'study': self.clientName, 'last_update': datetime.now() } # Should I do insert or upsert here? If a user has pre-registered for one # study and then pre-registers for another study before registering, do we # want to throw an error or just update silently? # Update silently for now writeResult = get_pending_signup_db().update( {'user_email': userEmail}, pendingDoc, upsert=True) print 'in __preRegister, writeResult = %s' % writeResult if 'err' in writeResult and writeResult['err'] is not None: e = Exception() e.code = writeResult['err'][0]["code"] e.msg = writeResult['err'][0]["errmsg"] raise e return (get_pending_signup_db().find({ 'study': self.clientName }).count(), userclient.countForStudy(self.clientName))
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 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 __preRegister(self, userEmail): from dao.user import User from main import userclient if User.isRegistered(userEmail): User.fromEmail(userEmail).setStudy(self.clientName) else: pendingDoc = { 'user_email': userEmail, 'study': self.clientName, 'last_update': datetime.now()} # Should I do insert or upsert here? If a user has pre-registered for one # study and then pre-registers for another study before registering, do we # want to throw an error or just update silently? # Update silently for now writeResult = get_pending_signup_db().update({'user_email': userEmail}, pendingDoc, upsert=True) print 'in __preRegister, writeResult = %s' % writeResult if 'err' in writeResult and writeResult['err'] is not None: e = Exception() e.code = writeResult['err'][0]["code"] e.msg = writeResult['err'][0]["errmsg"] raise e return (get_pending_signup_db().find({'study': self.clientName}).count(), userclient.countForStudy(self.clientName))
def testCountForStudyDefault(self): from get_database import get_profile_db, get_uuid_db, get_client_db, get_pending_signup_db user = User.register('*****@*****.**') self.assertEquals(userclient.countForStudy('testclient'), 0) self.assertEquals(userclient.countForStudy(None), 1)
def testCountForStudyZero(self): self.assertEquals(userclient.countForStudy('testclient'), 0)