예제 #1
0
  def testUnsetStudyExists(self):
    user = User.register('*****@*****.**')
    user.setStudy('testclient')
    self.assertEquals(userclient.countForStudy('testclient'), 1)

    user.unsetStudy('testclient')
    self.assertEquals(userclient.countForStudy('testclient'), 0)
예제 #2
0
    def testUnsetStudyExists(self):
        user = User.register('*****@*****.**')
        user.setStudy('testclient')
        self.assertEquals(userclient.countForStudy('testclient'), 1)

        user.unsetStudy('testclient')
        self.assertEquals(userclient.countForStudy('testclient'), 0)
예제 #3
0
    def __preRegister(self, userEmail):
        from emission.core.wrapper.user import User
        from emission.analysis.result 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))
예제 #4
0
  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)
예제 #5
0
    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)
예제 #6
0
  def __preRegister(self, userEmail):
    from emission.core.wrapper.user import User
    from emission.analysis.result 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))
예제 #7
0
 def testCountForStudyDefault(self):
     user = User.register('*****@*****.**')
     self.assertEquals(userclient.countForStudy('testclient'), 0)
     self.assertEquals(userclient.countForStudy(None), 1)
예제 #8
0
 def testCountForStudyZero(self):
     self.assertEquals(userclient.countForStudy('testclient'), 0)
예제 #9
0
 def testCountForStudyDefault(self):
   user = User.register('*****@*****.**')
   self.assertEquals(userclient.countForStudy('testclient'), 0)
   self.assertEquals(userclient.countForStudy(None), 1)
예제 #10
0
 def testCountForStudyZero(self):
   self.assertEquals(userclient.countForStudy('testclient'), 0)