Commits

Yuki KODAMA  committed 950a890

test: update test cases for API to regenerate address id

  • Participants
  • Parent commits f921035

Comments (0)

Files changed (1)

File tests/test_user_handler.py

         self.assertNotEqual(account, None)
 
         # regenerate address id
-        old_id = account.address_id
-        data = {'email': util.make_address(old_id)}
-        resp = app.post('/user/email/regen', params=data)
+        old_email = util.make_address(account.address_id)
+        resp = app.post('/user/email/regen', params={'email': old_email})
         self.assertEqual('200 OK', resp.status)
-        self.assertNotEqual(old_id, resp.json['email'])
+        self.assertNotEqual(old_email, resp.json['email'])
 
         account = model.Account.all().filter('twitter_id =', 'mail2tw').get()
         self.assertNotEqual(account, None)
-        new_id = account.address_id
-        self.assertEqual(util.make_address(new_id), resp.json['email'])
+        new_email = util.make_address(account.address_id)
+        self.assertEqual(new_email, resp.json['email'])
 
     def test_id_regen_badparam(self):
         account = model.Account.all().filter('twitter_id =', 'mail2tw').get()
         self.assertNotEqual(account, None)
 
-        # try to regenerate address id
-        # TODO
+        # invalid address id
+        old_email = util.make_address(account.address_id)
+        resp = app.post('/user/email/regen', params={'email': 'hoge'})
+        self.assertEqual('200 OK', resp.status)
+        self.assertEqual(old_email, resp.json['email'])
+
+        # without param
+        old_email = util.make_address(account.address_id)
+        resp = app.post('/user/email/regen')
+        self.assertEqual('200 OK', resp.status)
+        self.assertEqual(old_email, resp.json['email'])
 
     def test_forward_status_edit(self):
         # check current forwarding status