Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(341)

Side by Side Diff: appengine/swarming/handlers_api_test.py

Issue 1454913002: Get rid of usage of old Swarming API in tests. (Closed) Base URL: git@github.com:luci/luci-py.git@master
Patch Set: . Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | appengine/swarming/handlers_bot_test.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # coding: utf-8 2 # coding: utf-8
3 # Copyright 2014 The Swarming Authors. All rights reserved. 3 # Copyright 2014 The Swarming Authors. All rights reserved.
4 # Use of this source code is governed by the Apache v2.0 license that can be 4 # Use of this source code is governed by the Apache v2.0 license that can be
5 # found in the LICENSE file. 5 # found in the LICENSE file.
6 6
7 import base64 7 import base64
8 import datetime 8 import datetime
9 import logging 9 import logging
10 import os 10 import os
(...skipping 28 matching lines...) Expand all
39 extra_environ={ 39 extra_environ={
40 'REMOTE_ADDR': self.source_ip, 40 'REMOTE_ADDR': self.source_ip,
41 'SERVER_SOFTWARE': os.environ['SERVER_SOFTWARE'], 41 'SERVER_SOFTWARE': os.environ['SERVER_SOFTWARE'],
42 }) 42 })
43 self.mock( 43 self.mock(
44 ereporter2, 'log_request', 44 ereporter2, 'log_request',
45 lambda *args, **kwargs: self.fail('%s, %s' % (args, kwargs))) 45 lambda *args, **kwargs: self.fail('%s, %s' % (args, kwargs)))
46 # Client API test cases run by default as user. 46 # Client API test cases run by default as user.
47 self.set_as_user() 47 self.set_as_user()
48 48
49 def get_client_token(self):
50 """Gets the XSRF token for client after handshake."""
51 headers = {'X-XSRF-Token-Request': '1'}
52 params = {}
53 response = self.app.post_json(
54 '/swarming/api/v1/client/handshake',
55 headers=headers,
56 params=params).json
57 return response['xsrf_token'].encode('ascii')
58
49 def test_list(self): 59 def test_list(self):
50 self.set_as_anonymous() 60 self.set_as_anonymous()
51 response = self.app.get('/swarming/api/v1/client/list').json 61 response = self.app.get('/swarming/api/v1/client/list').json
52 expected = { 62 expected = {
53 u'bot/<bot_id:[^/]+>': u'Bot\'s meta data', 63 u'bot/<bot_id:[^/]+>': u'Bot\'s meta data',
54 u'bot/<bot_id:[^/]+>/tasks': u'Tasks executed on a specific bot', 64 u'bot/<bot_id:[^/]+>/tasks': u'Tasks executed on a specific bot',
55 u'bots': u'Bots known to the server', 65 u'bots': u'Bots known to the server',
56 u'list': u'All query handlers', 66 u'list': u'All query handlers',
57 u'server': u'Server details', 67 u'server': u'Server details',
58 u'task/<task_id:[0-9a-f]+>': u'Task\'s result meta data', 68 u'task/<task_id:[0-9a-f]+>': u'Task\'s result meta data',
(...skipping 867 matching lines...) Expand 10 before | Expand all | Expand 10 after
926 self.assertEqual(expected, actual) 936 self.assertEqual(expected, actual)
927 937
928 938
929 if __name__ == '__main__': 939 if __name__ == '__main__':
930 if '-v' in sys.argv: 940 if '-v' in sys.argv:
931 unittest.TestCase.maxDiff = None 941 unittest.TestCase.maxDiff = None
932 logging.basicConfig( 942 logging.basicConfig(
933 level=logging.DEBUG if '-v' in sys.argv else logging.CRITICAL, 943 level=logging.DEBUG if '-v' in sys.argv else logging.CRITICAL,
934 format='%(levelname)-7s %(filename)s:%(lineno)3d %(message)s') 944 format='%(levelname)-7s %(filename)s:%(lineno)3d %(message)s')
935 unittest.main() 945 unittest.main()
OLDNEW
« no previous file with comments | « no previous file | appengine/swarming/handlers_bot_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698