| 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 | 7 |
| 8 from components import auth | 8 from components import auth |
| 9 from components import utils | 9 from components import utils |
| 10 from google.appengine.ext import ndb | 10 from google.appengine.ext import ndb |
| 11 import mock | 11 import mock |
| 12 import gae_ts_mon |
| 12 | 13 |
| 13 from testing_utils import testing | 14 from testing_utils import testing |
| 14 import api | 15 import api |
| 15 import errors | 16 import errors |
| 16 import model | 17 import model |
| 17 import service | 18 import service |
| 18 | 19 |
| 19 | 20 |
| 20 class BuildBucketApiTest(testing.EndpointsTestCase): | 21 class BuildBucketApiTest(testing.EndpointsTestCase): |
| 21 api_service_cls = api.BuildBucketApi | 22 api_service_cls = api.BuildBucketApi |
| 22 | 23 |
| 23 def setUp(self): | 24 def setUp(self): |
| 24 super(BuildBucketApiTest, self).setUp() | 25 super(BuildBucketApiTest, self).setUp() |
| 26 gae_ts_mon.reset_for_unittest(disable=True) |
| 25 for a in dir(service): | 27 for a in dir(service): |
| 26 self.mock(service, a, mock.Mock()) | 28 self.mock(service, a, mock.Mock()) |
| 27 | 29 |
| 28 self.future_date = utils.utcnow() + datetime.timedelta(minutes=1) | 30 self.future_date = utils.utcnow() + datetime.timedelta(minutes=1) |
| 29 # future_ts is str because INT64 values are formatted as strings. | 31 # future_ts is str because INT64 values are formatted as strings. |
| 30 self.future_ts = str(utils.datetime_to_timestamp(self.future_date)) | 32 self.future_ts = str(utils.datetime_to_timestamp(self.future_date)) |
| 31 self.test_build = model.Build( | 33 self.test_build = model.Build( |
| 32 id=1, | 34 id=1, |
| 33 bucket='chromium', | 35 bucket='chromium', |
| 34 parameters={ | 36 parameters={ |
| (...skipping 518 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 553 def test_invalid_input_error(self): | 555 def test_invalid_input_error(self): |
| 554 self.error_test(errors.InvalidInputError, 'INVALID_INPUT') | 556 self.error_test(errors.InvalidInputError, 'INVALID_INPUT') |
| 555 | 557 |
| 556 def test_lease_expired_error(self): | 558 def test_lease_expired_error(self): |
| 557 self.error_test(errors.LeaseExpiredError, 'LEASE_EXPIRED') | 559 self.error_test(errors.LeaseExpiredError, 'LEASE_EXPIRED') |
| 558 | 560 |
| 559 def test_auth_error(self): | 561 def test_auth_error(self): |
| 560 with self.call_should_fail(403): | 562 with self.call_should_fail(403): |
| 561 service.get.side_effect = auth.AuthorizationError | 563 service.get.side_effect = auth.AuthorizationError |
| 562 self.call_api('get', {'id': 123}) | 564 self.call_api('get', {'id': 123}) |
| OLD | NEW |