示例#1
0
 def EntryHandler_postTest(self):
     weight = 75.0
     variance = 1.4
     currDate = "2012-10-10"
     currDt =dt.date(2012, 10, 10)
     nick= users.get_current_user().nickname()
     head = {"Content-Type" : "application/x-www-form-urlencoded", "Accept" : "text/plain"}
     payload = urlencode({"date" : currDate, "variance" : float(variance),"weight":float(weight)})
     #request = requests.Request("POST","/users/%s/"%nick, data=payload)
     request = webapp2.Request.blank('/users/%s/entry/%s'%(nick,currDate))
     request.method="POST"
     request.headers=head
     request.body=payload
     currUser=users.get_current_user()
     response = webapp2.Response()
     handler = EntryHandler()
     handler.initialize(request, response)
     handler.post(user=None,cd=None)
     self.setCurrentUser("*****@*****.**", "aaaaaaa")
     userId=users.get_current_user().user_id()
     db.delete(Entry.all())
     nick=users.get_current_user().nickname()
     handler.post(user=nick,cd='2012-10-10')
     Entry(weight=100.0, variance=5.0,date=currDt,user=currUser, parent=log_key(userId)).put()
     handler.post(user=nick,cd='2012-10-10')
     db.delete(Biometric.all())
     Biometric(height=150, target=73.3, parent=bio_key(currUser.user_id())).put()
     handler.post(user=nick,cd='2012-10-10')
     #Put Test
     handler.put(user=nick,cd='2012-10-10')
     handler.put(user=nick,cd='2012-10-15')
     handler.delete(user=nick,cd='2012-10-10')
示例#2
0
 def UserOverviewHandler_validateUserBiometricsTest(self):
     print('validateUserBiometricsTest')
     uoh = UserOverviewHandler()
     userId=users.get_current_user().user_id()
     bq = Biometric.all().ancestor(bio_key(userId))
     weight = 80.0
     height = 169
     target = 75.0
     uoh.validateUserBiometrics(bq,height,target,weight)
     height = 0
     uoh.validateUserBiometrics(bq,height,target,weight)
示例#3
0
 def RootHandler_buildTemplateTest(self):
     request = webapp2.Request.blank('/')
     uri = request.uri
     self.setCurrentUser("*****@*****.**", "root")
     userId=users.get_current_user().user_id()
     rh = RootHandler()
     Biometric(height=100, target=75.0, parent=bio_key(userId)).put()
     rh.buildTemplate(userId,uri)
     Entry(weight=100.1, parent=log_key(userId)).put()
     rh.buildTemplate(userId,uri)
     db.delete(Biometric.all())
     rh.buildTemplate(userId,uri)
示例#4
0
    def BMICheck_updateBMITest(self):
        b = BMICheck()
        currUser=users.get_current_user()
        request = webapp2.Request.blank('/')
        response = webapp2.Response()
        handler = UserOverviewHandler()
        handler.initialize(request, response)
        db.delete(Biometric.all())
        self.setCurrentUser("*****@*****.**", "aaaaaaa")
        Biometric(height=150, target=73.3, parent=bio_key(currUser.user_id())).put()
        Entry(weight=100.0,bmi=0.0, variance=5.0,date=self.toDate(2010,10,10),user=currUser, parent=log_key(currUser.user_id())).put()
        Entry(weight=110.0,bmi=0.0, variance=5.0,date=self.toDate(2010,10,11),user=currUser, parent=log_key(currUser.user_id())).put()
        Entry(weight=0.0,bmi=0.0, variance=5.0,date=self.toDate(2010,10,12),user=currUser, parent=log_key(currUser.user_id())).put()

        b.updateBMI(self,currUser.nickname())
示例#5
0
 def UserOverviewHandler_postTest(self):
     height = 169
     target = 75.5
     weight = 90.0
     nick= users.get_current_user().nickname()
     head = {"Content-Type" : "application/x-www-form-urlencoded", "Accept" : "text/plain"}
     payload = urlencode({"height" : int(height), "target" : float(target),"weight":float(weight)})
     #request = requests.Request("POST","/users/%s/"%nick, data=payload)
     request = webapp2.Request.blank('/users/%s/'%nick)
     request.method="POST"
     request.headers=head
     request.body=payload
     #request.query_string('height=169&weight=80&target=75')
     response = webapp2.Response()
     handler = UserOverviewHandler()
     handler.initialize(request, response)
     handler.post(user=None)
     self.setCurrentUser("*****@*****.**", "aaaaaaa")
     userId=users.get_current_user().user_id()
     db.delete(Biometric.all())
     handler.post(user=users.get_current_user().nickname())
     Biometric(height=100, target=75.0, parent=bio_key(userId)).put()
     handler.post(user=users.get_current_user().nickname())
示例#6
0
 def getUser(self,key):
     return Biometric.all().ancestor(bio_key(key))