Commits

Yuki KODAMA  committed f69bb1c

user: make endpoint urls consistent

  • Participants
  • Parent commits 9172a26

Comments (0)

Files changed (3)

 
         account = session['account']
 
-        if op == 'service/edit':
+        if op == 'account/status':
             status = self.request.get('status').strip()
             if status in ('running', 'stopped'):
                 account.status = status
             else:
                 data = {'status': account.status}
 
-        elif op == 'deactivate':
+        elif op == 'account/deactivate':
             account.delete()
             return self.redirect('/signout')
 
-        elif op == 'email/regen':
+        elif op == 'account/regen':
             email = self.request.get('email').strip()
             _, aid, _, _, _ = util.parse_address(email)
             if aid == account.address_id:

File static/js/user.js

     var status = tokens[2] == 'start' ? 'running' : 'stopped';
     $.ajax({
         type: 'POST',
-        url: '/user/service/edit',
+        url: '/user/account/status',
         data: {status: status},
         dataType: 'json',
         success: function(data){
         var email = $('.email .data a').html();
         $.ajax({
             type: 'POST',
-            url: '/user/email/regen',
+            url: '/user/account/regen',
             data: {email: email},
             dataType: 'json',
             success: function(data, status){
     confirm(MSG.deactivate.confirm, function(){
         $.ajax({
             type: 'POST',
-            url: '/user/deactivate',
+            url: '/user/account/deactivate',
             success: function(){
                 window.location.href = '/signout';
             },

File tests/test_user_handler.py

         return [tweet for tweet
                 in model.Tweet.all().filter('twitter_id =', tid)]
 
-    def test_service_edit(self):
+    def test_account_status(self):
         # check current service status
         account = model.Account.all().filter('twitter_id =', 'mail2tw').get()
         self.assertNotEqual(account, None)
         self.assertEqual('running', account.status)
 
         # valid request
-        resp = app.post('/user/service/edit', params={'status': 'stopped'})
+        resp = app.post('/user/account/status', params={'status': 'stopped'})
         self.assertEqual('200 OK', resp.status)
         self.assertEqual('stopped', resp.json['status'])
 
         self.assertNotEqual(account, None)
         self.assertEqual('stopped', account.status)
 
-        resp = app.post('/user/service/edit', params={'status': 'running'})
+        resp = app.post('/user/account/status', params={'status': 'running'})
         self.assertEqual('200 OK', resp.status)
         self.assertEqual('running', resp.json['status'])
 
         self.assertNotEqual(account, None)
         self.assertEqual('running', account.status)
 
-    def test_service_edit_badparam(self):
+    def test_account_status_badparam(self):
         # check current service status
         account = model.Account.all().filter('twitter_id =', 'mail2tw').get()
         self.assertNotEqual(account, None)
         self.assertEqual('running', account.status)
 
         # invalid request
-        resp = app.post('/user/service/edit', params={'status': 'hoge'})
+        resp = app.post('/user/account/status', params={'status': 'hoge'})
         self.assertEqual('200 OK', resp.status)
         self.assertEqual('running', resp.json['status'])
 
         self.assertNotEqual(account, None)
         self.assertEqual('running', account.status)
 
-        resp = app.post('/user/service/edit')
+        resp = app.post('/user/account/status')
         self.assertEqual('200 OK', resp.status)
         self.assertEqual('running', resp.json['status'])
 
         self.assertNotEqual(account, None)
 
         # deactivate account
-        resp = app.post('/user/deactivate')
+        resp = app.post('/user/account/deactivate')
         self.assertEqual('302 Moved Temporarily', resp.status)
         self.assertEqual('http://localhost/signout', resp.headers['Location'])
 
         account = model.Account.all().filter('twitter_id =', 'mail2tw').get()
         self.assertEqual(account, None)
 
-    def test_id_regen(self):
+    def test_account_regen(self):
         account = model.Account.all().filter('twitter_id =', 'mail2tw').get()
         self.assertNotEqual(account, None)
 
         # regenerate address id
         old_email = util.make_address(account.address_id)
-        resp = app.post('/user/email/regen', params={'email': old_email})
+        resp = app.post('/user/account/regen', params={'email': old_email})
         self.assertEqual('200 OK', resp.status)
         self.assertNotEqual(old_email, resp.json['email'])
 
         new_email = util.make_address(account.address_id)
         self.assertEqual(new_email, resp.json['email'])
 
-    def test_id_regen_badparam(self):
+    def test_account_regen_badparam(self):
         account = model.Account.all().filter('twitter_id =', 'mail2tw').get()
         self.assertNotEqual(account, None)
 
         # invalid address id
         old_email = util.make_address(account.address_id)
-        resp = app.post('/user/email/regen', params={'email': 'hoge'})
+        resp = app.post('/user/account/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')
+        resp = app.post('/user/account/regen')
         self.assertEqual('200 OK', resp.status)
         self.assertEqual(old_email, resp.json['email'])