OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # coding: utf-8 | 2 # coding: utf-8 |
3 # Copyright 2013 The LUCI Authors. All rights reserved. | 3 # Copyright 2013 The LUCI 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 itertools | 7 import itertools |
8 import logging | 8 import logging |
9 import os | 9 import os |
10 import re | 10 import re |
(...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
409 ' ', response.body) | 409 ' ', response.body) |
410 | 410 |
411 response = self.app.post( | 411 response = self.app.post( |
412 '/restricted/upload/bot_config?xsrf_token=%s' % xsrf_token, | 412 '/restricted/upload/bot_config?xsrf_token=%s' % xsrf_token, |
413 upload_files=[('script', 'script', u'script_bodé'.encode('utf-8'))]) | 413 upload_files=[('script', 'script', u'script_bodé'.encode('utf-8'))]) |
414 self.assertIn(u'script_bodé'.encode('utf-8'), response.body) | 414 self.assertIn(u'script_bodé'.encode('utf-8'), response.body) |
415 # TODO(maruel): Assert swarming_bot.zip now contains the new code. | 415 # TODO(maruel): Assert swarming_bot.zip now contains the new code. |
416 | 416 |
417 def test_config(self): | 417 def test_config(self): |
418 self.set_as_admin() | 418 self.set_as_admin() |
419 resp = self.app.get('/restricted/config') | 419 self.app.get('/restricted/config') |
420 # TODO(maruel): Use beautifulsoup? | |
421 params = { | |
422 'bot_death_timeout_secs': 10*60, | |
423 'google_analytics': 'foobar', | |
424 'keyid': str(config.settings().key.integer_id()), | |
425 'reusable_task_age_secs': 30, | |
426 'xsrf_token': self.get_xsrf_token(), | |
427 } | |
428 self.assertEqual('', config.settings().google_analytics) | |
429 resp = self.app.post('/restricted/config', params) | |
430 self.assertNotIn('Update conflict', resp) | |
431 self.assertEqual('foobar', config.settings().google_analytics) | |
432 self.assertIn('foobar', self.app.get('/').body) | |
433 | |
434 def test_config_conflict(self): | |
435 self.set_as_admin() | |
436 resp = self.app.get('/restricted/config') | |
437 # TODO(maruel): Use beautifulsoup? | |
438 params = { | |
439 'bot_death_timeout_secs': 10*60, | |
440 'google_analytics': 'foobar', | |
441 'keyid': str(config.settings().key.integer_id() - 1), | |
442 'reusable_task_age_secs': 30, | |
443 'xsrf_token': self.get_xsrf_token(), | |
444 } | |
445 self.assertEqual('', config.settings().google_analytics) | |
446 resp = self.app.post('/restricted/config', params) | |
447 self.assertIn('Update conflict', resp) | |
448 self.assertEqual('', config.settings().google_analytics) | |
449 | 420 |
450 | 421 |
451 class BackendTest(AppTestBase): | 422 class BackendTest(AppTestBase): |
452 def _GetRoutes(self): | 423 def _GetRoutes(self): |
453 """Returns the list of all routes handled.""" | 424 """Returns the list of all routes handled.""" |
454 return [ | 425 return [ |
455 r.template for r in self.app.app.router.match_routes | 426 r.template for r in self.app.app.router.match_routes |
456 ] | 427 ] |
457 | 428 |
458 def testCronJobTasks(self): | 429 def testCronJobTasks(self): |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
506 url, headers={'X-AppEngine-QueueName': 'bogus name'}, status=403) | 477 url, headers={'X-AppEngine-QueueName': 'bogus name'}, status=403) |
507 | 478 |
508 | 479 |
509 if __name__ == '__main__': | 480 if __name__ == '__main__': |
510 if '-v' in sys.argv: | 481 if '-v' in sys.argv: |
511 unittest.TestCase.maxDiff = None | 482 unittest.TestCase.maxDiff = None |
512 logging.basicConfig( | 483 logging.basicConfig( |
513 level=logging.DEBUG if '-v' in sys.argv else logging.CRITICAL, | 484 level=logging.DEBUG if '-v' in sys.argv else logging.CRITICAL, |
514 format='%(levelname)-7s %(filename)s:%(lineno)3d %(message)s') | 485 format='%(levelname)-7s %(filename)s:%(lineno)3d %(message)s') |
515 unittest.main() | 486 unittest.main() |
OLD | NEW |