예제 #1
0
 def EntryHandler_getTest(self):
     request = webapp2.Request.blank('/')
     response = webapp2.Response()
     handler = EntryHandler()
     currUser=users.get_current_user()
     nick=users.get_current_user().nickname()
     currDate=dt.date(2012, 10, 10)
     handler.initialize(request, response)
     handler.get(user=None,cd=None)
     self.setCurrentUser("*****@*****.**", "aaaaaaa")
     userId=users.get_current_user().user_id()
     handler.get(user=nick,cd='2012-10-10')
     Entry(weight=100.0, variance=5.0,date=currDate,user=currUser, parent=log_key(userId)).put()
     handler.get(user=nick,cd='2012-10-10')
예제 #2
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')