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

Side by Side Diff: appengine/chrome_infra_packages/cas/test/api_test.py

Issue 816433004: cipd: registerPackage method implementation. (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: Created 5 years, 11 months 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
OLDNEW
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 from testing_utils import testing 5 from testing_utils import testing
6 from components import auth_testing 6 from components import auth_testing
7 7
8 from cas import api 8 from cas import api
9 from cas import impl 9 from cas import impl
10 10
11 from . import common 11 from . import common
12 12
13 13
14 class CASServiceApiTest(testing.EndpointsTestCase): 14 class CASServiceApiTest(testing.EndpointsTestCase):
15 """Tests for API layer ONLY.""" 15 """Tests for API layer ONLY."""
16 16
17 api_service_cls = api.CASServiceApi 17 api_service_cls = api.CASServiceApi
18 18
19 def setUp(self): 19 def setUp(self):
20 super(CASServiceApiTest, self).setUp() 20 super(CASServiceApiTest, self).setUp()
21 auth_testing.mock_get_current_identity(self) 21 auth_testing.mock_get_current_identity(self)
22 auth_testing.mock_is_admin(self)
22 self.cas_service = common.MockedCASService() 23 self.cas_service = common.MockedCASService()
23 def mocked_get_cas_service(): 24 def mocked_get_cas_service():
24 return self.cas_service 25 return self.cas_service
25 self.mock(impl, 'get_cas_service', mocked_get_cas_service) 26 self.mock(impl, 'get_cas_service', mocked_get_cas_service)
26 27
27 def test_begin_upload_ok(self): 28 def test_begin_upload_ok(self):
28 resp = self.call_api('begin_upload', { 29 resp = self.call_api('begin_upload', {
29 'hash_algo': 'SHA1', 30 'hash_algo': 'SHA1',
30 'file_hash': 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 31 'file_hash': 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
31 }) 32 })
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 # Mock 'fetch_upload_session' to return errored session. 85 # Mock 'fetch_upload_session' to return errored session.
85 errored_session = common.make_fake_session() 86 errored_session = common.make_fake_session()
86 errored_session.status = impl.UploadSession.STATUS_ERROR 87 errored_session.status = impl.UploadSession.STATUS_ERROR
87 errored_session.error_message = 'Life is sad' 88 errored_session.error_message = 'Life is sad'
88 self.cas_service.fetch_upload_session = lambda *_: errored_session 89 self.cas_service.fetch_upload_session = lambda *_: errored_session
89 resp = self.call_api('finish_upload', {'upload_session_id': 'signed_id'}) 90 resp = self.call_api('finish_upload', {'upload_session_id': 'signed_id'})
90 self.assertEqual(resp.json, { 91 self.assertEqual(resp.json, {
91 'status': 'ERROR', 92 'status': 'ERROR',
92 'error_message': 'Life is sad', 93 'error_message': 'Life is sad',
93 }) 94 })
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698