Commits

Yuki KODAMA committed 9172a26

user: set empty string to 'id' value if error

Comments (0)

Files changed (2)

                         tweet.status = status
                         tweet.put()
                         data['status'] = tweet.status
+                    else:
+                        data['id'] = ''
 
                 elif op == 'tweet/time':
                     time = self.request.get('time').strip()

tests/test_user_handler.py

         self.assertEqual(5, len(tweets))
 
         # try to set a status text which overs 140 chars
-        tweet_id = tweets.pop().key().id()
+        tweet = tweets.pop()
+        old_status = tweet.status
+        tweet_id = tweet.key().id()
         data = {'id': tweet_id,
                 'status': 'Hello world!' * 12}
         resp = app.post('/user/tweet/status', params=data)
         self.assertEqual('200 OK', resp.status)
         self.assertEqual('', resp.json['id'])
-        self.assertEqual('modified!', resp.json['status'])
+        self.assertFalse(resp.json.has_key('status'))
 
         tweet = model.Tweet.get_by_id(tweet_id)
         self.assertNotEqual(None, tweet)
-        self.assertEqual('modified!', tweet.status)
-
-        # TODO: recheck
+        self.assertEqual(old_status, tweet.status)
 
     def test_tweet_status_badparam(self):
         # call without param