| OLD | NEW |
| 1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 import datetime | 5 import datetime |
| 6 import json | 6 import json |
| 7 import os | 7 import os |
| 8 import sys | 8 import sys |
| 9 | 9 |
| 10 REPO_ROOT_DIR = os.path.abspath(os.path.join( | 10 REPO_ROOT_DIR = os.path.abspath(os.path.join( |
| (...skipping 602 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 613 def test_invalid_input_error(self): | 613 def test_invalid_input_error(self): |
| 614 self.error_test(errors.InvalidInputError, 'INVALID_INPUT') | 614 self.error_test(errors.InvalidInputError, 'INVALID_INPUT') |
| 615 | 615 |
| 616 def test_lease_expired_error(self): | 616 def test_lease_expired_error(self): |
| 617 self.error_test(errors.LeaseExpiredError, 'LEASE_EXPIRED') | 617 self.error_test(errors.LeaseExpiredError, 'LEASE_EXPIRED') |
| 618 | 618 |
| 619 def test_auth_error(self): | 619 def test_auth_error(self): |
| 620 service.get.side_effect = auth.AuthorizationError | 620 service.get.side_effect = auth.AuthorizationError |
| 621 self.call_api('get', {'id': 123}, status=403) | 621 self.call_api('get', {'id': 123}, status=403) |
| 622 | 622 |
| 623 ############################# LONGEST_PENDING_TIME ########################### |
| 624 |
| 625 def test_longest_pending_time(self): |
| 626 service.longest_pending_time.return_value = datetime.timedelta(seconds=42) |
| 627 req = { |
| 628 'bucket': 'chromium', |
| 629 'builder': 'x', |
| 630 } |
| 631 res = self.call_api('longest_pending_time', req).json_body |
| 632 self.assertEqual(res['longest_pending_time_sec'], 42) |
| 633 service.longest_pending_time.assert_called_once_with('chromium', 'x') |
| 634 |
| 623 | 635 |
| 624 class EndpointsApiTest(testing.EndpointsTestCase, ApiTests): | 636 class EndpointsApiTest(testing.EndpointsTestCase, ApiTests): |
| 625 api_service_cls = api.BuildBucketApi | 637 api_service_cls = api.BuildBucketApi |
| 626 | 638 |
| 627 def setUp(self): | 639 def setUp(self): |
| 628 super(EndpointsApiTest, self).setUp() | 640 super(EndpointsApiTest, self).setUp() |
| 629 self.setUpTests() | 641 self.setUpTests() |
| 630 | 642 |
| 631 | 643 |
| 632 class Webapp2ApiTest(test_case.Webapp2EndpointsTestCase, ApiTests): | 644 class Webapp2ApiTest(test_case.Webapp2EndpointsTestCase, ApiTests): |
| 633 api_service_cls = api.BuildBucketApi | 645 api_service_cls = api.BuildBucketApi |
| 634 | 646 |
| 635 def setUp(self): | 647 def setUp(self): |
| 636 super(Webapp2ApiTest, self).setUp() | 648 super(Webapp2ApiTest, self).setUp() |
| 637 self.setUpTests() | 649 self.setUpTests() |
| OLD | NEW |