forked from luci/luci-py
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhandlers_test.py
More file actions
executable file
·50 lines (37 loc) · 1.4 KB
/
handlers_test.py
File metadata and controls
executable file
·50 lines (37 loc) · 1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/env python
# Copyright 2015 The LUCI Authors. All rights reserved.
# Use of this source code is governed by the Apache v2.0 license that can be
# found in the LICENSE file.
from test_env import future
import test_env
test_env.setup_test_env()
import mock
import webtest
from components.config.proto import service_config_pb2
from test_support import test_case
import main
import storage
class HandlersTest(test_case.TestCase):
def setUp(self):
super(HandlersTest, self).setUp()
self.app = webtest.TestApp(main.create_html_app())
def test_schemas(self):
self.mock(storage, 'get_self_config_async', mock.Mock())
storage.get_self_config_async.return_value = future(
service_config_pb2.SchemasCfg(
schemas=[
service_config_pb2.SchemasCfg.Schema(
name='projects/refs.cfg',
url='http://somehost/refs.proto',
)],
))
response = self.app.get('/schemas/projects/refs.cfg', status=302)
self.assertEqual(
'http://somehost/refs.proto', response.headers.get('Location'))
self.app.get('/schemas/non-existent', status=404)
def test_schemas_no_schemas_cfg(self):
self.mock(storage, 'get_latest_as_message_async', mock.Mock())
storage.get_latest_as_message_async.return_value = future(None)
self.app.get('/schemas/non-existent', status=404)
if __name__ == '__main__':
test_env.main()