Пример #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 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))
Пример #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 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))
Пример #7
0
 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)
Пример #8
0
 def testCountForStudyZero(self):
     self.assertEquals(userclient.countForStudy('testclient'), 0)
Пример #9
0
 def testCountForStudyZero(self):
   self.assertEquals(userclient.countForStudy('testclient'), 0)
Пример #10
0
 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)